Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Browse files Browse the repository at this point in the history
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 <davem@davemloft.net>
  • Loading branch information
David S. Miller committed May 2, 2020
2 parents 5b95dea + 57dc6f3 commit 115506f
Show file tree
Hide file tree
Showing 153 changed files with 6,739 additions and 3,367 deletions.
2 changes: 1 addition & 1 deletion arch/arm64/kernel/armv8_deprecated.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static void __init register_insn_emulation(struct insn_emulation_ops *ops)
}

static int emulation_proc_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
void *buffer, size_t *lenp,
loff_t *ppos)
{
int ret = 0;
Expand Down
3 changes: 1 addition & 2 deletions arch/arm64/kernel/fpsimd.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,7 @@ static unsigned int find_supported_vector_length(unsigned int vl)
#ifdef CONFIG_SYSCTL

static int sve_proc_do_default_vl(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
int ret;
int vl = sve_default_vl;
Expand Down
13 changes: 5 additions & 8 deletions arch/mips/lasat/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,15 @@ int proc_lasat_ip(struct ctl_table *table, int write,
len = 0;
p = buffer;
while (len < *lenp) {
if (get_user(c, p++))
return -EFAULT;
c = *p;
p++;
if (c == 0 || c == '\n')
break;
len++;
}
if (len >= sizeof(ipbuf)-1)
len = sizeof(ipbuf) - 1;
if (copy_from_user(ipbuf, buffer, len))
return -EFAULT;
memcpy(ipbuf, buffer, len);
ipbuf[len] = 0;
*ppos += *lenp;
/* Now see if we can convert it to a valid IP */
Expand All @@ -122,11 +121,9 @@ int proc_lasat_ip(struct ctl_table *table, int write,
if (len > *lenp)
len = *lenp;
if (len)
if (copy_to_user(buffer, ipbuf, len))
return -EFAULT;
memcpy(buffer, ipbuf, len);
if (len < *lenp) {
if (put_user('\n', ((char *) buffer) + len))
return -EFAULT;
*((char *)buffer + len) = '\n';
len++;
}
*lenp = len;
Expand Down
103 changes: 68 additions & 35 deletions arch/riscv/net/bpf_jit_comp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,35 @@
#include <linux/filter.h>
#include "bpf_jit.h"

/*
* Stack layout during BPF program execution:
*
* high
* RV32 fp => +----------+
* | saved ra |
* | saved fp | RV32 callee-saved registers
* | ... |
* +----------+ <= (fp - 4 * NR_SAVED_REGISTERS)
* | hi(R6) |
* | lo(R6) |
* | hi(R7) | JIT scratch space for BPF registers
* | lo(R7) |
* | ... |
* BPF_REG_FP => +----------+ <= (fp - 4 * NR_SAVED_REGISTERS
* | | - 4 * BPF_JIT_SCRATCH_REGS)
* | |
* | ... | BPF program stack
* | |
* RV32 sp => +----------+
* | |
* | ... | Function call stack
* | |
* +----------+
* low
*/

enum {
/* Stack layout - these are offsets from (top of stack - 4). */
/* Stack layout - these are offsets from top of JIT scratch space. */
BPF_R6_HI,
BPF_R6_LO,
BPF_R7_HI,
Expand All @@ -29,7 +56,11 @@ enum {
BPF_JIT_SCRATCH_REGS,
};

#define STACK_OFFSET(k) (-4 - ((k) * 4))
/* Number of callee-saved registers stored to stack: ra, fp, s1--s7. */
#define NR_SAVED_REGISTERS 9

/* Offset from fp for BPF registers stored on stack. */
#define STACK_OFFSET(k) (-4 - (4 * NR_SAVED_REGISTERS) - (4 * (k)))

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

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

store_offset -= 4 * BPF_JIT_SCRATCH_REGS;

/* Set return value if not tail call. */
if (!is_tail_call) {
emit(rv_addi(RV_REG_A0, lo(r0), 0), ctx);
emit(rv_addi(RV_REG_A1, hi(r0), 0), ctx);
}

/* Restore callee-saved registers. */
emit(rv_lw(RV_REG_RA, store_offset - 0, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_FP, store_offset - 4, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S1, store_offset - 8, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S2, store_offset - 12, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S3, store_offset - 16, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S4, store_offset - 20, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S5, store_offset - 24, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S6, store_offset - 28, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S7, store_offset - 32, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_RA, stack_adjust - 4, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_FP, stack_adjust - 8, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S1, stack_adjust - 12, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S2, stack_adjust - 16, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S3, stack_adjust - 20, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S4, stack_adjust - 24, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S5, stack_adjust - 28, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S6, stack_adjust - 32, RV_REG_SP), ctx);
emit(rv_lw(RV_REG_S7, stack_adjust - 36, RV_REG_SP), ctx);

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

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

/*
* if ((temp_tcc = tcc - 1) < 0)
* temp_tcc = tcc - 1;
* if (tcc < 0)
* goto out;
*/
emit(rv_addi(RV_REG_T1, RV_REG_TCC, -1), ctx);
off = (tc_ninsn - (ctx->ninsns - start_insn)) << 2;
emit_bcc(BPF_JSLT, RV_REG_T1, RV_REG_ZERO, off, ctx);
emit_bcc(BPF_JSLT, RV_REG_TCC, RV_REG_ZERO, off, ctx);

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

void bpf_jit_build_prologue(struct rv_jit_context *ctx)
{
/* Make space to save 9 registers: ra, fp, s1--s7. */
int stack_adjust = 9 * sizeof(u32), store_offset, bpf_stack_adjust;
const s8 *fp = bpf2rv32[BPF_REG_FP];
const s8 *r1 = bpf2rv32[BPF_REG_1];

bpf_stack_adjust = round_up(ctx->prog->aux->stack_depth, 16);
int stack_adjust = 0;
int bpf_stack_adjust =
round_up(ctx->prog->aux->stack_depth, STACK_ALIGN);

/* Make space for callee-saved registers. */
stack_adjust += NR_SAVED_REGISTERS * sizeof(u32);
/* Make space for BPF registers on stack. */
stack_adjust += BPF_JIT_SCRATCH_REGS * sizeof(u32);
/* Make space for BPF stack. */
stack_adjust += bpf_stack_adjust;

store_offset = stack_adjust - 4;

stack_adjust += 4 * BPF_JIT_SCRATCH_REGS;
/* Round up for stack alignment. */
stack_adjust = round_up(stack_adjust, STACK_ALIGN);

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

/* Save callee-save registers. */
emit(rv_sw(RV_REG_SP, store_offset - 0, RV_REG_RA), ctx);
emit(rv_sw(RV_REG_SP, store_offset - 4, RV_REG_FP), ctx);
emit(rv_sw(RV_REG_SP, store_offset - 8, RV_REG_S1), ctx);
emit(rv_sw(RV_REG_SP, store_offset - 12, RV_REG_S2), ctx);
emit(rv_sw(RV_REG_SP, store_offset - 16, RV_REG_S3), ctx);
emit(rv_sw(RV_REG_SP, store_offset - 20, RV_REG_S4), ctx);
emit(rv_sw(RV_REG_SP, store_offset - 24, RV_REG_S5), ctx);
emit(rv_sw(RV_REG_SP, store_offset - 28, RV_REG_S6), ctx);
emit(rv_sw(RV_REG_SP, store_offset - 32, RV_REG_S7), ctx);
emit(rv_sw(RV_REG_SP, stack_adjust - 4, RV_REG_RA), ctx);
emit(rv_sw(RV_REG_SP, stack_adjust - 8, RV_REG_FP), ctx);
emit(rv_sw(RV_REG_SP, stack_adjust - 12, RV_REG_S1), ctx);
emit(rv_sw(RV_REG_SP, stack_adjust - 16, RV_REG_S2), ctx);
emit(rv_sw(RV_REG_SP, stack_adjust - 20, RV_REG_S3), ctx);
emit(rv_sw(RV_REG_SP, stack_adjust - 24, RV_REG_S4), ctx);
emit(rv_sw(RV_REG_SP, stack_adjust - 28, RV_REG_S5), ctx);
emit(rv_sw(RV_REG_SP, stack_adjust - 32, RV_REG_S6), ctx);
emit(rv_sw(RV_REG_SP, stack_adjust - 36, RV_REG_S7), ctx);

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

/* Set up BPF stack pointer. */
/* Set up BPF frame pointer. */
emit(rv_addi(lo(fp), RV_REG_SP, bpf_stack_adjust), ctx);
emit(rv_addi(hi(fp), RV_REG_ZERO, 0), ctx);

/* Set up context pointer. */
/* Set up BPF context pointer. */
emit(rv_addi(lo(r1), RV_REG_A0, 0), ctx);
emit(rv_addi(hi(r1), RV_REG_ZERO, 0), ctx);

Expand Down
11 changes: 5 additions & 6 deletions arch/s390/appldata/appldata_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ static struct platform_device *appldata_pdev;
*/
static const char appldata_proc_name[APPLDATA_PROC_NAME_LENGTH] = "appldata";
static int appldata_timer_handler(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos);
void *buffer, size_t *lenp, loff_t *ppos);
static int appldata_interval_handler(struct ctl_table *ctl, int write,
void __user *buffer,
size_t *lenp, loff_t *ppos);
void *buffer, size_t *lenp, loff_t *ppos);

static struct ctl_table_header *appldata_sysctl_header;
static struct ctl_table appldata_table[] = {
Expand Down Expand Up @@ -217,7 +216,7 @@ static void __appldata_vtimer_setup(int cmd)
*/
static int
appldata_timer_handler(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
int timer_active = appldata_timer_active;
int rc;
Expand Down Expand Up @@ -250,7 +249,7 @@ appldata_timer_handler(struct ctl_table *ctl, int write,
*/
static int
appldata_interval_handler(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
int interval = appldata_interval;
int rc;
Expand Down Expand Up @@ -280,7 +279,7 @@ appldata_interval_handler(struct ctl_table *ctl, int write,
*/
static int
appldata_generic_handler(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
struct appldata_ops *ops = NULL, *tmp_ops;
struct list_head *lh;
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kernel/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ static int debug_active = 1;
* if debug_active is already off
*/
static int s390dbf_procactive(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
if (!write || debug_stoppable || !debug_active)
return proc_dointvec(table, write, buffer, lenp, ppos);
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ static int __init topology_setup(char *str)
early_param("topology", topology_setup);

static int topology_ctl_handler(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
int enabled = topology_is_enabled();
int new_mode;
Expand Down
12 changes: 5 additions & 7 deletions arch/s390/mm/cmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static int cmm_skip_blanks(char *cp, char **endp)
}

static int cmm_pages_handler(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
long nr = cmm_get_pages();
struct ctl_table ctl_entry = {
Expand All @@ -264,7 +264,7 @@ static int cmm_pages_handler(struct ctl_table *ctl, int write,
}

static int cmm_timed_pages_handler(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp,
void *buffer, size_t *lenp,
loff_t *ppos)
{
long nr = cmm_get_timed_pages();
Expand All @@ -284,7 +284,7 @@ static int cmm_timed_pages_handler(struct ctl_table *ctl, int write,
}

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

if (write) {
len = min(*lenp, sizeof(buf));
if (copy_from_user(buf, buffer, len))
return -EFAULT;
memcpy(buf, buffer, len);
buf[len - 1] = '\0';
cmm_skip_blanks(buf, &p);
nr = simple_strtoul(p, &p, 0);
Expand All @@ -311,8 +310,7 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write,
cmm_timeout_pages, cmm_timeout_seconds);
if (len > *lenp)
len = *lenp;
if (copy_to_user(buffer, buf, len))
return -EFAULT;
memcpy(buffer, buf, len);
*lenp = len;
*ppos += len;
}
Expand Down
3 changes: 1 addition & 2 deletions arch/x86/kernel/itmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ static bool __read_mostly sched_itmt_capable;
unsigned int __read_mostly sysctl_sched_itmt_enabled;

static int sched_itmt_update_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
unsigned int old_sysctl;
int ret;
Expand Down
2 changes: 1 addition & 1 deletion drivers/cdrom/cdrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -3631,7 +3631,7 @@ static void cdrom_update_settings(void)
}

static int cdrom_sysctl_handler(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
int ret;

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ static char sysctl_bootid[16];
* sysctl system call, as 16 bytes of binary data.
*/
static int proc_do_uuid(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
struct ctl_table fake_table;
unsigned char buf[64], tmp_uuid[16], *uuid;
Expand Down
3 changes: 1 addition & 2 deletions drivers/macintosh/mac_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ static void mac_hid_stop_emulation(void)
}

static int mac_hid_toggle_emumouse(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
int *valp = table->data;
int old_val = *valp;
Expand Down
2 changes: 2 additions & 0 deletions drivers/media/rc/bpf-lirc.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ lirc_mode2_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return &bpf_map_peek_elem_proto;
case BPF_FUNC_ktime_get_ns:
return &bpf_ktime_get_ns_proto;
case BPF_FUNC_ktime_get_boot_ns:
return &bpf_ktime_get_boot_ns_proto;
case BPF_FUNC_tail_call:
return &bpf_tail_call_proto;
case BPF_FUNC_get_prandom_u32:
Expand Down
Loading

0 comments on commit 115506f

Please sign in to comment.