Skip to content

Commit 339bbff

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Daniel Borkmann says: ==================== pull-request: bpf-next 2018-12-21 The following pull-request contains BPF updates for your *net-next* tree. There is a merge conflict in test_verifier.c. Result looks as follows: [...] }, { "calls: cross frame pruning", .insns = { [...] .prog_type = BPF_PROG_TYPE_SOCKET_FILTER, .errstr_unpriv = "function calls to other bpf functions are allowed for root only", .result_unpriv = REJECT, .errstr = "!read_ok", .result = REJECT, }, { "jset: functional", .insns = { [...] { "jset: unknown const compare not taken", .insns = { BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_prandom_u32), BPF_JMP_IMM(BPF_JSET, BPF_REG_0, 1, 1), BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0), BPF_EXIT_INSN(), }, .prog_type = BPF_PROG_TYPE_SOCKET_FILTER, .errstr_unpriv = "!read_ok", .result_unpriv = REJECT, .errstr = "!read_ok", .result = REJECT, }, [...] { "jset: range", .insns = { [...] }, .prog_type = BPF_PROG_TYPE_SOCKET_FILTER, .result_unpriv = ACCEPT, .result = ACCEPT, }, The main changes are: 1) Various BTF related improvements in order to get line info working. Meaning, verifier will now annotate the corresponding BPF C code to the error log, from Martin and Yonghong. 2) Implement support for raw BPF tracepoints in modules, from Matt. 3) Add several improvements to verifier state logic, namely speeding up stacksafe check, optimizations for stack state equivalence test and safety checks for liveness analysis, from Alexei. 4) Teach verifier to make use of BPF_JSET instruction, add several test cases to kselftests and remove nfp specific JSET optimization now that verifier has awareness, from Jakub. 5) Improve BPF verifier's slot_type marking logic in order to allow more stack slot sharing, from Jiong. 6) Add sk_msg->size member for context access and add set of fixes and improvements to make sock_map with kTLS usable with openssl based applications, from John. 7) Several cleanups and documentation updates in bpftool as well as auto-mount of tracefs for "bpftool prog tracelog" command, from Quentin. 8) Include sub-program tags from now on in bpf_prog_info in order to have a reliable way for user space to get all tags of the program e.g. needed for kallsyms correlation, from Song. 9) Add BTF annotations for cgroup_local_storage BPF maps and implement bpf fs pretty print support, from Roman. 10) Fix bpftool in order to allow for cross-compilation, from Ivan. 11) Update of bpftool license to GPLv2-only + BSD-2-Clause in order to be compatible with libbfd and allow for Debian packaging, from Jakub. 12) Remove an obsolete prog->aux sanitation in dump and get rid of version check for prog load, from Daniel. 13) Fix a memory leak in libbpf's line info handling, from Prashant. 14) Fix cpumap's frame alignment for build_skb() so that skb_shared_info does not get unaligned, from Jesper. 15) Fix test_progs kselftest to work with older compilers which are less smart in optimizing (and thus throwing build error), from Stanislav. 16) Cleanup and simplify AF_XDP socket teardown, from Björn. 17) Fix sk lookup in BPF kselftest's test_sock_addr with regards to netns_id argument, from Andrey. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents e770454 + 1cf4a0c commit 339bbff

Some content is hidden

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

64 files changed

+2331
-680
lines changed

arch/arm64/net/bpf_jit_comp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
932932
prog->jited_len = image_size;
933933

934934
if (!prog->is_func || extra_pass) {
935+
bpf_prog_fill_jited_linfo(prog, ctx.offset);
935936
out_off:
936937
kfree(ctx.offset);
937938
kfree(jit_data);

arch/sparc/net/bpf_jit_comp_64.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
15751575
prog->jited_len = image_size;
15761576

15771577
if (!prog->is_func || extra_pass) {
1578+
bpf_prog_fill_jited_linfo(prog, ctx.offset);
15781579
out_off:
15791580
kfree(ctx.offset);
15801581
kfree(jit_data);

drivers/net/ethernet/netronome/nfp/bpf/jit.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3052,26 +3052,19 @@ static int jset_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
30523052
{
30533053
const struct bpf_insn *insn = &meta->insn;
30543054
u64 imm = insn->imm; /* sign extend */
3055+
u8 dst_gpr = insn->dst_reg * 2;
30553056
swreg tmp_reg;
30563057

3057-
if (!imm) {
3058-
meta->skip = true;
3059-
return 0;
3060-
}
3061-
3062-
if (imm & ~0U) {
3063-
tmp_reg = ur_load_imm_any(nfp_prog, imm & ~0U, imm_b(nfp_prog));
3064-
emit_alu(nfp_prog, reg_none(),
3065-
reg_a(insn->dst_reg * 2), ALU_OP_AND, tmp_reg);
3066-
emit_br(nfp_prog, BR_BNE, insn->off, 0);
3067-
}
3068-
3069-
if (imm >> 32) {
3070-
tmp_reg = ur_load_imm_any(nfp_prog, imm >> 32, imm_b(nfp_prog));
3058+
tmp_reg = ur_load_imm_any(nfp_prog, imm & ~0U, imm_b(nfp_prog));
3059+
emit_alu(nfp_prog, imm_b(nfp_prog),
3060+
reg_a(dst_gpr), ALU_OP_AND, tmp_reg);
3061+
/* Upper word of the mask can only be 0 or ~0 from sign extension,
3062+
* so either ignore it or OR the whole thing in.
3063+
*/
3064+
if (imm >> 32)
30713065
emit_alu(nfp_prog, reg_none(),
3072-
reg_a(insn->dst_reg * 2 + 1), ALU_OP_AND, tmp_reg);
3073-
emit_br(nfp_prog, BR_BNE, insn->off, 0);
3074-
}
3066+
reg_a(dst_gpr + 1), ALU_OP_OR, imm_b(nfp_prog));
3067+
emit_br(nfp_prog, BR_BNE, insn->off, 0);
30753068

30763069
return 0;
30773070
}

include/linux/bpf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct bpf_prog;
2323
struct bpf_map;
2424
struct sock;
2525
struct seq_file;
26+
struct btf;
2627
struct btf_type;
2728

2829
/* map is generic key/value storage optionally accesible by eBPF programs */
@@ -52,6 +53,7 @@ struct bpf_map_ops {
5253
void (*map_seq_show_elem)(struct bpf_map *map, void *key,
5354
struct seq_file *m);
5455
int (*map_check_btf)(const struct bpf_map *map,
56+
const struct btf *btf,
5557
const struct btf_type *key_type,
5658
const struct btf_type *value_type);
5759
};
@@ -126,6 +128,7 @@ static inline bool bpf_map_support_seq_show(const struct bpf_map *map)
126128
}
127129

128130
int map_check_no_btf(const struct bpf_map *map,
131+
const struct btf *btf,
129132
const struct btf_type *key_type,
130133
const struct btf_type *value_type);
131134

include/linux/bpf_verifier.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ enum bpf_reg_liveness {
3838
REG_LIVE_NONE = 0, /* reg hasn't been read or written this branch */
3939
REG_LIVE_READ, /* reg was read, so we're sensitive to initial value */
4040
REG_LIVE_WRITTEN, /* reg was written first, screening off later reads */
41+
REG_LIVE_DONE = 4, /* liveness won't be updating this register anymore */
4142
};
4243

4344
struct bpf_reg_state {
@@ -224,6 +225,7 @@ struct bpf_verifier_env {
224225
bool allow_ptr_leaks;
225226
bool seen_direct_write;
226227
struct bpf_insn_aux_data *insn_aux_data; /* array of per-insn state */
228+
const struct bpf_line_info *prev_linfo;
227229
struct bpf_verifier_log log;
228230
struct bpf_subprog_info subprog_info[BPF_MAX_SUBPROGS + 1];
229231
u32 subprog_cnt;

include/linux/btf.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/types.h>
88

99
struct btf;
10+
struct btf_member;
1011
struct btf_type;
1112
union bpf_attr;
1213

@@ -46,7 +47,9 @@ void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj,
4647
struct seq_file *m);
4748
int btf_get_fd_by_id(u32 id);
4849
u32 btf_id(const struct btf *btf);
49-
bool btf_name_offset_valid(const struct btf *btf, u32 offset);
50+
bool btf_member_is_reg_int(const struct btf *btf, const struct btf_type *s,
51+
const struct btf_member *m,
52+
u32 expected_offset, u32 expected_size);
5053

5154
#ifdef CONFIG_BPF_SYSCALL
5255
const struct btf_type *btf_type_by_id(const struct btf *btf, u32 type_id);

include/linux/module.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ struct module {
432432
unsigned int num_tracepoints;
433433
tracepoint_ptr_t *tracepoints_ptrs;
434434
#endif
435+
#ifdef CONFIG_BPF_EVENTS
436+
unsigned int num_bpf_raw_events;
437+
struct bpf_raw_event_map *bpf_raw_events;
438+
#endif
435439
#ifdef HAVE_JUMP_LABEL
436440
struct jump_entry *jump_entries;
437441
unsigned int num_jump_entries;

include/linux/skmsg.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct sk_msg_sg {
3636
struct scatterlist data[MAX_MSG_FRAGS + 1];
3737
};
3838

39+
/* UAPI in filter.c depends on struct sk_msg_sg being first element. */
3940
struct sk_msg {
4041
struct sk_msg_sg sg;
4142
void *data;
@@ -416,6 +417,14 @@ static inline void sk_psock_put(struct sock *sk, struct sk_psock *psock)
416417
sk_psock_drop(sk, psock);
417418
}
418419

420+
static inline void sk_psock_data_ready(struct sock *sk, struct sk_psock *psock)
421+
{
422+
if (psock->parser.enabled)
423+
psock->parser.saved_data_ready(sk);
424+
else
425+
sk->sk_data_ready(sk);
426+
}
427+
419428
static inline void psock_set_prog(struct bpf_prog **pprog,
420429
struct bpf_prog *prog)
421430
{

include/linux/socket.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ struct ucred {
286286
#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */
287287
#define MSG_MORE 0x8000 /* Sender will send more */
288288
#define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */
289+
#define MSG_SENDPAGE_NOPOLICY 0x10000 /* sendpage() internal : do no apply policy */
289290
#define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */
290291
#define MSG_BATCH 0x40000 /* sendmmsg(): more messages coming */
291292
#define MSG_EOF MSG_FIN

include/linux/trace_events.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ void perf_event_detach_bpf_prog(struct perf_event *event);
471471
int perf_event_query_prog_array(struct perf_event *event, void __user *info);
472472
int bpf_probe_register(struct bpf_raw_event_map *btp, struct bpf_prog *prog);
473473
int bpf_probe_unregister(struct bpf_raw_event_map *btp, struct bpf_prog *prog);
474-
struct bpf_raw_event_map *bpf_find_raw_tracepoint(const char *name);
474+
struct bpf_raw_event_map *bpf_get_raw_tracepoint(const char *name);
475+
void bpf_put_raw_tracepoint(struct bpf_raw_event_map *btp);
475476
int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id,
476477
u32 *fd_type, const char **buf,
477478
u64 *probe_offset, u64 *probe_addr);
@@ -502,10 +503,13 @@ static inline int bpf_probe_unregister(struct bpf_raw_event_map *btp, struct bpf
502503
{
503504
return -EOPNOTSUPP;
504505
}
505-
static inline struct bpf_raw_event_map *bpf_find_raw_tracepoint(const char *name)
506+
static inline struct bpf_raw_event_map *bpf_get_raw_tracepoint(const char *name)
506507
{
507508
return NULL;
508509
}
510+
static inline void bpf_put_raw_tracepoint(struct bpf_raw_event_map *btp)
511+
{
512+
}
509513
static inline int bpf_get_perf_event_info(const struct perf_event *event,
510514
u32 *prog_id, u32 *fd_type,
511515
const char **buf, u64 *probe_offset,

0 commit comments

Comments
 (0)