Skip to content

Commit 115506f

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Alexei Starovoitov says: ==================== pull-request: bpf-next 2020-05-01 (v2) The following pull-request contains BPF updates for your *net-next* tree. We've added 61 non-merge commits during the last 6 day(s) which contain a total of 153 files changed, 6739 insertions(+), 3367 deletions(-). The main changes are: 1) pulled work.sysctl from vfs tree with sysctl bpf changes. 2) bpf_link observability, from Andrii. 3) BTF-defined map in map, from Andrii. 4) asan fixes for selftests, from Andrii. 5) Allow bpf_map_lookup_elem for SOCKMAP and SOCKHASH, from Jakub. 6) production cloudflare classifier as a selftes, from Lorenz. 7) bpf_ktime_get_*_ns() helper improvements, from Maciej. 8) unprivileged bpftool feature probe, from Quentin. 9) BPF_ENABLE_STATS command, from Song. 10) enable bpf_[gs]etsockopt() helpers for sock_ops progs, from Stanislav. 11) enable a bunch of common helpers for cg-device, sysctl, sockopt progs, from Stanislav. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 5b95dea + 57dc6f3 commit 115506f

File tree

153 files changed

+6739
-3367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+6739
-3367
lines changed

arch/arm64/kernel/armv8_deprecated.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static void __init register_insn_emulation(struct insn_emulation_ops *ops)
203203
}
204204

205205
static int emulation_proc_handler(struct ctl_table *table, int write,
206-
void __user *buffer, size_t *lenp,
206+
void *buffer, size_t *lenp,
207207
loff_t *ppos)
208208
{
209209
int ret = 0;

arch/arm64/kernel/fpsimd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,7 @@ static unsigned int find_supported_vector_length(unsigned int vl)
341341
#ifdef CONFIG_SYSCTL
342342

343343
static int sve_proc_do_default_vl(struct ctl_table *table, int write,
344-
void __user *buffer, size_t *lenp,
345-
loff_t *ppos)
344+
void *buffer, size_t *lenp, loff_t *ppos)
346345
{
347346
int ret;
348347
int vl = sve_default_vl;

arch/mips/lasat/sysctl.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,15 @@ int proc_lasat_ip(struct ctl_table *table, int write,
9595
len = 0;
9696
p = buffer;
9797
while (len < *lenp) {
98-
if (get_user(c, p++))
99-
return -EFAULT;
98+
c = *p;
99+
p++;
100100
if (c == 0 || c == '\n')
101101
break;
102102
len++;
103103
}
104104
if (len >= sizeof(ipbuf)-1)
105105
len = sizeof(ipbuf) - 1;
106-
if (copy_from_user(ipbuf, buffer, len))
107-
return -EFAULT;
106+
memcpy(ipbuf, buffer, len);
108107
ipbuf[len] = 0;
109108
*ppos += *lenp;
110109
/* Now see if we can convert it to a valid IP */
@@ -122,11 +121,9 @@ int proc_lasat_ip(struct ctl_table *table, int write,
122121
if (len > *lenp)
123122
len = *lenp;
124123
if (len)
125-
if (copy_to_user(buffer, ipbuf, len))
126-
return -EFAULT;
124+
memcpy(buffer, ipbuf, len);
127125
if (len < *lenp) {
128-
if (put_user('\n', ((char *) buffer) + len))
129-
return -EFAULT;
126+
*((char *)buffer + len) = '\n';
130127
len++;
131128
}
132129
*lenp = len;

arch/riscv/net/bpf_jit_comp32.c

Lines changed: 68 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,35 @@
1313
#include <linux/filter.h>
1414
#include "bpf_jit.h"
1515

16+
/*
17+
* Stack layout during BPF program execution:
18+
*
19+
* high
20+
* RV32 fp => +----------+
21+
* | saved ra |
22+
* | saved fp | RV32 callee-saved registers
23+
* | ... |
24+
* +----------+ <= (fp - 4 * NR_SAVED_REGISTERS)
25+
* | hi(R6) |
26+
* | lo(R6) |
27+
* | hi(R7) | JIT scratch space for BPF registers
28+
* | lo(R7) |
29+
* | ... |
30+
* BPF_REG_FP => +----------+ <= (fp - 4 * NR_SAVED_REGISTERS
31+
* | | - 4 * BPF_JIT_SCRATCH_REGS)
32+
* | |
33+
* | ... | BPF program stack
34+
* | |
35+
* RV32 sp => +----------+
36+
* | |
37+
* | ... | Function call stack
38+
* | |
39+
* +----------+
40+
* low
41+
*/
42+
1643
enum {
17-
/* Stack layout - these are offsets from (top of stack - 4). */
44+
/* Stack layout - these are offsets from top of JIT scratch space. */
1845
BPF_R6_HI,
1946
BPF_R6_LO,
2047
BPF_R7_HI,
@@ -29,7 +56,11 @@ enum {
2956
BPF_JIT_SCRATCH_REGS,
3057
};
3158

32-
#define STACK_OFFSET(k) (-4 - ((k) * 4))
59+
/* Number of callee-saved registers stored to stack: ra, fp, s1--s7. */
60+
#define NR_SAVED_REGISTERS 9
61+
62+
/* Offset from fp for BPF registers stored on stack. */
63+
#define STACK_OFFSET(k) (-4 - (4 * NR_SAVED_REGISTERS) - (4 * (k)))
3364

3465
#define TMP_REG_1 (MAX_BPF_JIT_REG + 0)
3566
#define TMP_REG_2 (MAX_BPF_JIT_REG + 1)
@@ -111,27 +142,25 @@ static void emit_imm64(const s8 *rd, s32 imm_hi, s32 imm_lo,
111142

112143
static void __build_epilogue(bool is_tail_call, struct rv_jit_context *ctx)
113144
{
114-
int stack_adjust = ctx->stack_size, store_offset = stack_adjust - 4;
145+
int stack_adjust = ctx->stack_size;
115146
const s8 *r0 = bpf2rv32[BPF_REG_0];
116147

117-
store_offset -= 4 * BPF_JIT_SCRATCH_REGS;
118-
119148
/* Set return value if not tail call. */
120149
if (!is_tail_call) {
121150
emit(rv_addi(RV_REG_A0, lo(r0), 0), ctx);
122151
emit(rv_addi(RV_REG_A1, hi(r0), 0), ctx);
123152
}
124153

125154
/* Restore callee-saved registers. */
126-
emit(rv_lw(RV_REG_RA, store_offset - 0, RV_REG_SP), ctx);
127-
emit(rv_lw(RV_REG_FP, store_offset - 4, RV_REG_SP), ctx);
128-
emit(rv_lw(RV_REG_S1, store_offset - 8, RV_REG_SP), ctx);
129-
emit(rv_lw(RV_REG_S2, store_offset - 12, RV_REG_SP), ctx);
130-
emit(rv_lw(RV_REG_S3, store_offset - 16, RV_REG_SP), ctx);
131-
emit(rv_lw(RV_REG_S4, store_offset - 20, RV_REG_SP), ctx);
132-
emit(rv_lw(RV_REG_S5, store_offset - 24, RV_REG_SP), ctx);
133-
emit(rv_lw(RV_REG_S6, store_offset - 28, RV_REG_SP), ctx);
134-
emit(rv_lw(RV_REG_S7, store_offset - 32, RV_REG_SP), ctx);
155+
emit(rv_lw(RV_REG_RA, stack_adjust - 4, RV_REG_SP), ctx);
156+
emit(rv_lw(RV_REG_FP, stack_adjust - 8, RV_REG_SP), ctx);
157+
emit(rv_lw(RV_REG_S1, stack_adjust - 12, RV_REG_SP), ctx);
158+
emit(rv_lw(RV_REG_S2, stack_adjust - 16, RV_REG_SP), ctx);
159+
emit(rv_lw(RV_REG_S3, stack_adjust - 20, RV_REG_SP), ctx);
160+
emit(rv_lw(RV_REG_S4, stack_adjust - 24, RV_REG_SP), ctx);
161+
emit(rv_lw(RV_REG_S5, stack_adjust - 28, RV_REG_SP), ctx);
162+
emit(rv_lw(RV_REG_S6, stack_adjust - 32, RV_REG_SP), ctx);
163+
emit(rv_lw(RV_REG_S7, stack_adjust - 36, RV_REG_SP), ctx);
135164

136165
emit(rv_addi(RV_REG_SP, RV_REG_SP, stack_adjust), ctx);
137166

@@ -770,12 +799,13 @@ static int emit_bpf_tail_call(int insn, struct rv_jit_context *ctx)
770799
emit_bcc(BPF_JGE, lo(idx_reg), RV_REG_T1, off, ctx);
771800

772801
/*
773-
* if ((temp_tcc = tcc - 1) < 0)
802+
* temp_tcc = tcc - 1;
803+
* if (tcc < 0)
774804
* goto out;
775805
*/
776806
emit(rv_addi(RV_REG_T1, RV_REG_TCC, -1), ctx);
777807
off = (tc_ninsn - (ctx->ninsns - start_insn)) << 2;
778-
emit_bcc(BPF_JSLT, RV_REG_T1, RV_REG_ZERO, off, ctx);
808+
emit_bcc(BPF_JSLT, RV_REG_TCC, RV_REG_ZERO, off, ctx);
779809

780810
/*
781811
* prog = array->ptrs[index];
@@ -1259,17 +1289,20 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
12591289

12601290
void bpf_jit_build_prologue(struct rv_jit_context *ctx)
12611291
{
1262-
/* Make space to save 9 registers: ra, fp, s1--s7. */
1263-
int stack_adjust = 9 * sizeof(u32), store_offset, bpf_stack_adjust;
12641292
const s8 *fp = bpf2rv32[BPF_REG_FP];
12651293
const s8 *r1 = bpf2rv32[BPF_REG_1];
1266-
1267-
bpf_stack_adjust = round_up(ctx->prog->aux->stack_depth, 16);
1294+
int stack_adjust = 0;
1295+
int bpf_stack_adjust =
1296+
round_up(ctx->prog->aux->stack_depth, STACK_ALIGN);
1297+
1298+
/* Make space for callee-saved registers. */
1299+
stack_adjust += NR_SAVED_REGISTERS * sizeof(u32);
1300+
/* Make space for BPF registers on stack. */
1301+
stack_adjust += BPF_JIT_SCRATCH_REGS * sizeof(u32);
1302+
/* Make space for BPF stack. */
12681303
stack_adjust += bpf_stack_adjust;
1269-
1270-
store_offset = stack_adjust - 4;
1271-
1272-
stack_adjust += 4 * BPF_JIT_SCRATCH_REGS;
1304+
/* Round up for stack alignment. */
1305+
stack_adjust = round_up(stack_adjust, STACK_ALIGN);
12731306

12741307
/*
12751308
* The first instruction sets the tail-call-counter (TCC) register.
@@ -1280,24 +1313,24 @@ void bpf_jit_build_prologue(struct rv_jit_context *ctx)
12801313
emit(rv_addi(RV_REG_SP, RV_REG_SP, -stack_adjust), ctx);
12811314

12821315
/* Save callee-save registers. */
1283-
emit(rv_sw(RV_REG_SP, store_offset - 0, RV_REG_RA), ctx);
1284-
emit(rv_sw(RV_REG_SP, store_offset - 4, RV_REG_FP), ctx);
1285-
emit(rv_sw(RV_REG_SP, store_offset - 8, RV_REG_S1), ctx);
1286-
emit(rv_sw(RV_REG_SP, store_offset - 12, RV_REG_S2), ctx);
1287-
emit(rv_sw(RV_REG_SP, store_offset - 16, RV_REG_S3), ctx);
1288-
emit(rv_sw(RV_REG_SP, store_offset - 20, RV_REG_S4), ctx);
1289-
emit(rv_sw(RV_REG_SP, store_offset - 24, RV_REG_S5), ctx);
1290-
emit(rv_sw(RV_REG_SP, store_offset - 28, RV_REG_S6), ctx);
1291-
emit(rv_sw(RV_REG_SP, store_offset - 32, RV_REG_S7), ctx);
1316+
emit(rv_sw(RV_REG_SP, stack_adjust - 4, RV_REG_RA), ctx);
1317+
emit(rv_sw(RV_REG_SP, stack_adjust - 8, RV_REG_FP), ctx);
1318+
emit(rv_sw(RV_REG_SP, stack_adjust - 12, RV_REG_S1), ctx);
1319+
emit(rv_sw(RV_REG_SP, stack_adjust - 16, RV_REG_S2), ctx);
1320+
emit(rv_sw(RV_REG_SP, stack_adjust - 20, RV_REG_S3), ctx);
1321+
emit(rv_sw(RV_REG_SP, stack_adjust - 24, RV_REG_S4), ctx);
1322+
emit(rv_sw(RV_REG_SP, stack_adjust - 28, RV_REG_S5), ctx);
1323+
emit(rv_sw(RV_REG_SP, stack_adjust - 32, RV_REG_S6), ctx);
1324+
emit(rv_sw(RV_REG_SP, stack_adjust - 36, RV_REG_S7), ctx);
12921325

12931326
/* Set fp: used as the base address for stacked BPF registers. */
12941327
emit(rv_addi(RV_REG_FP, RV_REG_SP, stack_adjust), ctx);
12951328

1296-
/* Set up BPF stack pointer. */
1329+
/* Set up BPF frame pointer. */
12971330
emit(rv_addi(lo(fp), RV_REG_SP, bpf_stack_adjust), ctx);
12981331
emit(rv_addi(hi(fp), RV_REG_ZERO, 0), ctx);
12991332

1300-
/* Set up context pointer. */
1333+
/* Set up BPF context pointer. */
13011334
emit(rv_addi(lo(r1), RV_REG_A0, 0), ctx);
13021335
emit(rv_addi(hi(r1), RV_REG_ZERO, 0), ctx);
13031336

arch/s390/appldata/appldata_base.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ static struct platform_device *appldata_pdev;
5151
*/
5252
static const char appldata_proc_name[APPLDATA_PROC_NAME_LENGTH] = "appldata";
5353
static int appldata_timer_handler(struct ctl_table *ctl, int write,
54-
void __user *buffer, size_t *lenp, loff_t *ppos);
54+
void *buffer, size_t *lenp, loff_t *ppos);
5555
static int appldata_interval_handler(struct ctl_table *ctl, int write,
56-
void __user *buffer,
57-
size_t *lenp, loff_t *ppos);
56+
void *buffer, size_t *lenp, loff_t *ppos);
5857

5958
static struct ctl_table_header *appldata_sysctl_header;
6059
static struct ctl_table appldata_table[] = {
@@ -217,7 +216,7 @@ static void __appldata_vtimer_setup(int cmd)
217216
*/
218217
static int
219218
appldata_timer_handler(struct ctl_table *ctl, int write,
220-
void __user *buffer, size_t *lenp, loff_t *ppos)
219+
void *buffer, size_t *lenp, loff_t *ppos)
221220
{
222221
int timer_active = appldata_timer_active;
223222
int rc;
@@ -250,7 +249,7 @@ appldata_timer_handler(struct ctl_table *ctl, int write,
250249
*/
251250
static int
252251
appldata_interval_handler(struct ctl_table *ctl, int write,
253-
void __user *buffer, size_t *lenp, loff_t *ppos)
252+
void *buffer, size_t *lenp, loff_t *ppos)
254253
{
255254
int interval = appldata_interval;
256255
int rc;
@@ -280,7 +279,7 @@ appldata_interval_handler(struct ctl_table *ctl, int write,
280279
*/
281280
static int
282281
appldata_generic_handler(struct ctl_table *ctl, int write,
283-
void __user *buffer, size_t *lenp, loff_t *ppos)
282+
void *buffer, size_t *lenp, loff_t *ppos)
284283
{
285284
struct appldata_ops *ops = NULL, *tmp_ops;
286285
struct list_head *lh;

arch/s390/kernel/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ static int debug_active = 1;
867867
* if debug_active is already off
868868
*/
869869
static int s390dbf_procactive(struct ctl_table *table, int write,
870-
void __user *buffer, size_t *lenp, loff_t *ppos)
870+
void *buffer, size_t *lenp, loff_t *ppos)
871871
{
872872
if (!write || debug_stoppable || !debug_active)
873873
return proc_dointvec(table, write, buffer, lenp, ppos);

arch/s390/kernel/topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static int __init topology_setup(char *str)
594594
early_param("topology", topology_setup);
595595

596596
static int topology_ctl_handler(struct ctl_table *ctl, int write,
597-
void __user *buffer, size_t *lenp, loff_t *ppos)
597+
void *buffer, size_t *lenp, loff_t *ppos)
598598
{
599599
int enabled = topology_is_enabled();
600600
int new_mode;

arch/s390/mm/cmm.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static int cmm_skip_blanks(char *cp, char **endp)
245245
}
246246

247247
static int cmm_pages_handler(struct ctl_table *ctl, int write,
248-
void __user *buffer, size_t *lenp, loff_t *ppos)
248+
void *buffer, size_t *lenp, loff_t *ppos)
249249
{
250250
long nr = cmm_get_pages();
251251
struct ctl_table ctl_entry = {
@@ -264,7 +264,7 @@ static int cmm_pages_handler(struct ctl_table *ctl, int write,
264264
}
265265

266266
static int cmm_timed_pages_handler(struct ctl_table *ctl, int write,
267-
void __user *buffer, size_t *lenp,
267+
void *buffer, size_t *lenp,
268268
loff_t *ppos)
269269
{
270270
long nr = cmm_get_timed_pages();
@@ -284,7 +284,7 @@ static int cmm_timed_pages_handler(struct ctl_table *ctl, int write,
284284
}
285285

286286
static int cmm_timeout_handler(struct ctl_table *ctl, int write,
287-
void __user *buffer, size_t *lenp, loff_t *ppos)
287+
void *buffer, size_t *lenp, loff_t *ppos)
288288
{
289289
char buf[64], *p;
290290
long nr, seconds;
@@ -297,8 +297,7 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write,
297297

298298
if (write) {
299299
len = min(*lenp, sizeof(buf));
300-
if (copy_from_user(buf, buffer, len))
301-
return -EFAULT;
300+
memcpy(buf, buffer, len);
302301
buf[len - 1] = '\0';
303302
cmm_skip_blanks(buf, &p);
304303
nr = simple_strtoul(p, &p, 0);
@@ -311,8 +310,7 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write,
311310
cmm_timeout_pages, cmm_timeout_seconds);
312311
if (len > *lenp)
313312
len = *lenp;
314-
if (copy_to_user(buffer, buf, len))
315-
return -EFAULT;
313+
memcpy(buffer, buf, len);
316314
*lenp = len;
317315
*ppos += len;
318316
}

arch/x86/kernel/itmt.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ static bool __read_mostly sched_itmt_capable;
3939
unsigned int __read_mostly sysctl_sched_itmt_enabled;
4040

4141
static int sched_itmt_update_handler(struct ctl_table *table, int write,
42-
void __user *buffer, size_t *lenp,
43-
loff_t *ppos)
42+
void *buffer, size_t *lenp, loff_t *ppos)
4443
{
4544
unsigned int old_sysctl;
4645
int ret;

drivers/cdrom/cdrom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3631,7 +3631,7 @@ static void cdrom_update_settings(void)
36313631
}
36323632

36333633
static int cdrom_sysctl_handler(struct ctl_table *ctl, int write,
3634-
void __user *buffer, size_t *lenp, loff_t *ppos)
3634+
void *buffer, size_t *lenp, loff_t *ppos)
36353635
{
36363636
int ret;
36373637

drivers/char/random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ static char sysctl_bootid[16];
20572057
* sysctl system call, as 16 bytes of binary data.
20582058
*/
20592059
static int proc_do_uuid(struct ctl_table *table, int write,
2060-
void __user *buffer, size_t *lenp, loff_t *ppos)
2060+
void *buffer, size_t *lenp, loff_t *ppos)
20612061
{
20622062
struct ctl_table fake_table;
20632063
unsigned char buf[64], tmp_uuid[16], *uuid;

drivers/macintosh/mac_hid.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ static void mac_hid_stop_emulation(void)
183183
}
184184

185185
static int mac_hid_toggle_emumouse(struct ctl_table *table, int write,
186-
void __user *buffer, size_t *lenp,
187-
loff_t *ppos)
186+
void *buffer, size_t *lenp, loff_t *ppos)
188187
{
189188
int *valp = table->data;
190189
int old_val = *valp;

drivers/media/rc/bpf-lirc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ lirc_mode2_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
103103
return &bpf_map_peek_elem_proto;
104104
case BPF_FUNC_ktime_get_ns:
105105
return &bpf_ktime_get_ns_proto;
106+
case BPF_FUNC_ktime_get_boot_ns:
107+
return &bpf_ktime_get_boot_ns_proto;
106108
case BPF_FUNC_tail_call:
107109
return &bpf_tail_call_proto;
108110
case BPF_FUNC_get_prandom_u32:

0 commit comments

Comments
 (0)