History

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. ====================

David S. Miller committed 7 years ago

Commit 339bbff2 parents e770454 1cf4a0c64 files · +2331 −680Browse files

Showing the changes to tools/include/uapi (2 of 64 files). Show all

Unified · Split

2 files
  1. tools/include/uapi/linux/bpf.h +12 −1
  2. tools/include/uapi/linux/btf.h +18 −2
tools/include/uapi/linux/bpf.h+12−1
@@ -133,6 +133,14 @@ enum bpf_map_type { · 132 unmodified lines
133133 BPF_MAP_TYPE_STACK,
134134 };
135135
136+/* Note that tracing related programs such as
137+ * BPF_PROG_TYPE_{KPROBE,TRACEPOINT,PERF_EVENT,RAW_TRACEPOINT}
138+ * are not subject to a stable API since kernel internal data
139+ * structures can change from release to release and may
140+ * therefore break existing tracing BPF programs. Tracing BPF
141+ * programs correspond to /a/ specific kernel which is to be
142+ * analyzed, and not /a/ specific kernel /and/ all future ones.
143+ */
136144 enum bpf_prog_type {
137145 BPF_PROG_TYPE_UNSPEC,
138146 BPF_PROG_TYPE_SOCKET_FILTER,
@@ -343,7 +351,7 @@ union bpf_attr { · 204 unmodified lines
343351 __u32 log_level; /* verbosity level of verifier */
344352 __u32 log_size; /* size of user buffer */
345353 __aligned_u64 log_buf; /* user supplied buffer */
346− __u32 kern_version; /* checked when prog_type=kprobe */
354+ __u32 kern_version; /* not used */
347355 __u32 prog_flags;
348356 char prog_name[BPF_OBJ_NAME_LEN];
349357 __u32 prog_ifindex; /* ifindex of netdev to prep for */
@@ -2657,6 +2665,7 @@ struct sk_msg_md { · 2307 unmodified lines
26572665 __u32 local_ip6[4]; /* Stored in network byte order */
26582666 __u32 remote_port; /* Stored in network byte order */
26592667 __u32 local_port; /* stored in host byte order */
2668+ __u32 size; /* Total size of sk_msg */
26602669 };
26612670
26622671 struct sk_reuseport_md {
@@ -2717,6 +2726,8 @@ struct bpf_prog_info { · 54 unmodified lines
27172726 __u32 nr_jited_line_info;
27182727 __u32 line_info_rec_size;
27192728 __u32 jited_line_info_rec_size;
2729+ __u32 nr_prog_tags;
2730+ __aligned_u64 prog_tags;
27202731 } __attribute__((aligned(8)));
27212732
27222733 struct bpf_map_info {
tools/include/uapi/linux/btf.h+18−2
@@ -34,7 +34,9 @@ struct btf_type { · 33 unmodified lines
3434 * bits 0-15: vlen (e.g. # of struct's members)
3535 * bits 16-23: unused
3636 * bits 24-27: kind (e.g. int, ptr, array...etc)
37− * bits 28-31: unused
37+ * bits 28-30: unused
38+ * bit 31: kind_flag, currently used by
39+ * struct, union and fwd
3840 */
3941 __u32 info;
4042 /* "size" is used by INT, ENUM, STRUCT and UNION.
@@ -52,6 +54,7 @@ struct btf_type { · 11 unmodified lines
5254
5355 #define BTF_INFO_KIND(info) (((info) >> 24) & 0x0f)
5456 #define BTF_INFO_VLEN(info) ((info) & 0xffff)
57+#define BTF_INFO_KFLAG(info) ((info) >> 31)
5558
5659 #define BTF_KIND_UNKN 0 /* Unknown */
5760 #define BTF_KIND_INT 1 /* Integer */
@@ -110,9 +113,22 @@ struct btf_array { · 52 unmodified lines
110113 struct btf_member {
111114 __u32 name_off;
112115 __u32 type;
113− __u32 offset; /* offset in bits */
116+ /* If the type info kind_flag is set, the btf_member offset
117+ * contains both member bitfield size and bit offset. The
118+ * bitfield size is set for bitfield members. If the type
119+ * info kind_flag is not set, the offset contains only bit
120+ * offset.
121+ */
122+ __u32 offset;
114123 };
115124
125+/* If the struct/union type info kind_flag is set, the
126+ * following two macros are used to access bitfield_size
127+ * and bit_offset from btf_member.offset.
128+ */
129+#define BTF_MEMBER_BITFIELD_SIZE(val) ((val) >> 24)
130+#define BTF_MEMBER_BIT_OFFSET(val) ((val) & 0xffffff)
131+
116132 /* BTF_KIND_FUNC_PROTO is followed by multiple "struct btf_param".
117133 * The exact number of btf_param is stored in the vlen (of the
118134 * info in "struct btf_type").