History

Merge tag 'bpf-next-7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next

Pull bpf updates from Alexei Starovoitov: "Major changes: - Recover from BPF arena page faults using a scratch page and add ptep_try_set() for lockless empty-slot installs on x86 and arm64. This allows BPF kfuncs to access arena pointers directly. The 'arena_direct_access' stable branch was created for this work and was pulled into sched-ext and bpf-next trees (Tejun Heo, Kumar Kartikeya Dwivedi) - Lift old restriction and support 6+ arguments in BPF programs and kfuncs on x86 and arm64 (Yonghong Song, Puranjay Mohan) Other features and fixes: - Add 24-bit BTF vlen and reclaim unused bits in the BTF UAPI to ease addition of new BTF kinds (Alan Maguire) - Raise the maximum BPF call chain depth from 8 to 16 frames (Alexei Starovoitov) - Refactor object relationship tracking in the verifier and fix a dynptr use-after-free bug (Amery Hung) - Harden the signed program loader and reject exclusive maps as inner maps (Daniel Borkmann) - Replace the verifier min/max bounds fields with a circular number (cnum) representation and improve 32->64 bit range refinements (Eduard Zingerman) - Introduce the arena library and runtime (libarena) with a buddy allocator, rbtree and SPMC queue data structures, ASAN support and a parallel test harness. Allow subprograms to return arena pointers and switch to a BTF type-tag based __arena annotation (Emil Tsalapatis) - Cache build IDs in the sleepable stackmap path and avoid faultable build ID reads under mm locks (Ihor Solodrai) - Introduce the tracing_multi link to attach a single BPF program to many kernel functions at once. Allow specifying the uprobe_multi target via FD (Jiri Olsa) - Extend the bpf_list family of kfuncs with bpf_list_add/del(), and bpf_list_is_first/is_last/empty() (Kaitao Cheng) - Extend the BPF syscall with common attributes support for prog_load, btf_load and map_create (Leon Hwang) - Wrap rhashtable as BPF map (Mykyta Yatsenko, Herbert Xu) - Add sleepable support for tracepoint programs and fix deadlocks in LRU map due to NMI reentry (Mykyta Yatsenko) - Fix OOB access in bpf_flow_keys, fix nullness analysis of inner arrays, enforce write checks for global subprograms (Nuoqi Gui) - Report the maximum combined stack depth and print a breakdown of instructions processed per subprogram (Paul Chaignon) - Add an XDP load-balancer benchmark and arm64 JIT support for stack arguments (Puranjay Mohan) - Add kfuncs to traverse over wakeup_sources (Samuel Wu) - Allow sleepable BPF programs to use LPM trie maps directly (Vlad Poenaru) - Many more fixes and cleanups across the verifier, BTF, sockmap, devmap, bpffs, security hooks, s390/riscv/loongarch JITs, rqspinlock, libbpf, bpftool, selftests" * tag 'bpf-next-7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: (336 commits) selftests/bpf: Work around llvm stack overflow in crypto progs selftests/bpf: add test for bpf_msg_pop_data() overflow bpf, sockmap: fix integer overflow in bpf_msg_pop_data() bounds check sockmap: Fix use-after-free in udp_bpf_recvmsg() bpf, sockmap: keep sk_msg copy state in sync bpf, sockmap: Fix wrong rsge offset in bpf_msg_push_data() bpf, sockmap: reject overflowing copy + len in bpf_msg_push_data() selftsets/bpf: Retry map update on helper_fill_hashmap() selftests/bpf: Add test for sleepable lsm_cgroup rejection selftests/bpf: Add test to verify the fix for bpf_setsockopt() helper bpf: Fix bpf_get/setsockopt to tos for ipv4-mapped ipv6 socket selftests/bpf: Avoid static LLVM linking for cross builds selftests/bpf: Use common CFLAGS for urandom_read selftests/bpf: Initialize operation name before use tools/bpf: build: Append extra cflags libbpf: Initialize CFLAGS before including Makefile.include bpftool: Append extra host flags bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS bpftool: Pass host flags to bootstrap libbpf selftests/bpf: correct CONFIG_PPC64 macro name in comment ...

Linus Torvalds committed 4 months ago

Commit 9c87e612 parents b85966a e4287bf349 files · +27861 −4982Browse files

Showing the changes to include/uapi/linux (2 of 349 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/bpf.h +31 −1
  2. include/uapi/linux/btf.h +14 −12
include/uapi/linux/bpf.h+31−1
@@ -994,6 +994,7 @@ enum bpf_cmd { · 993 unmodified lines
994994 BPF_PROG_STREAM_READ_BY_FD,
995995 BPF_PROG_ASSOC_STRUCT_OPS,
996996 __MAX_BPF_CMD,
997+ BPF_COMMON_ATTRS = 1 << 16, /* Indicate carrying syscall common attrs. */
997998 };
998999
9991000 enum bpf_map_type {
@@ -1046,6 +1047,7 @@ enum bpf_map_type { · 46 unmodified lines
10461047 BPF_MAP_TYPE_CGRP_STORAGE,
10471048 BPF_MAP_TYPE_ARENA,
10481049 BPF_MAP_TYPE_INSN_ARRAY,
1050+ BPF_MAP_TYPE_RHASH,
10491051 __MAX_BPF_MAP_TYPE
10501052 };
10511053
@@ -1154,6 +1156,9 @@ enum bpf_attach_type { · 102 unmodified lines
11541156 BPF_TRACE_KPROBE_SESSION,
11551157 BPF_TRACE_UPROBE_SESSION,
11561158 BPF_TRACE_FSESSION,
1159+ BPF_TRACE_FENTRY_MULTI,
1160+ BPF_TRACE_FEXIT_MULTI,
1161+ BPF_TRACE_FSESSION_MULTI,
11571162 __MAX_BPF_ATTACH_TYPE
11581163 };
11591164
@@ -1178,6 +1183,7 @@ enum bpf_link_type { · 18 unmodified lines
11781183 BPF_LINK_TYPE_UPROBE_MULTI = 12,
11791184 BPF_LINK_TYPE_NETKIT = 13,
11801185 BPF_LINK_TYPE_SOCKMAP = 14,
1186+ BPF_LINK_TYPE_TRACING_MULTI = 15,
11811187 __MAX_BPF_LINK_TYPE,
11821188 };
11831189
@@ -1321,7 +1327,11 @@ enum { · 137 unmodified lines
13211327 * BPF_TRACE_UPROBE_MULTI attach type to create return probe.
13221328 */
13231329 enum {
1324− BPF_F_UPROBE_MULTI_RETURN = (1U << 0)
1330+ /* Get return uprobe. */
1331+ BPF_F_UPROBE_MULTI_RETURN = (1U << 0),
1332+
1333+ /* Get path from provided path_fd. */
1334+ BPF_F_UPROBE_MULTI_PATH_FD = (1U << 1),
13251335 };
13261336
13271337 /* link_create.netfilter.flags used in LINK_CREATE command for
@@ -1500,6 +1510,13 @@ struct bpf_stack_build_id { · 172 unmodified lines
15001510 };
15011511 };
15021512
1513+struct bpf_common_attr {
1514+ __aligned_u64 log_buf;
1515+ __u32 log_size;
1516+ __u32 log_level;
1517+ __u32 log_true_size;
1518+};
1519+
15031520 #define BPF_OBJ_NAME_LEN 16U
15041521
15051522 enum {
@@ -1537,6 +1554,11 @@ union bpf_attr { · 31 unmodified lines
15371554 *
15381555 * BPF_MAP_TYPE_ARENA - contains the address where user space
15391556 * is going to mmap() the arena. It has to be page aligned.
1557+ *
1558+ * BPF_MAP_TYPE_RHASH - initial table size hint
1559+ * (nelem_hint). 0 = use rhashtable default. Must be
1560+ * <= min(max_entries, U16_MAX). Upper 32 bits reserved,
1561+ * must be zero.
15401562 */
15411563 __u64 map_extra;
15421564
@@ -1846,6 +1868,7 @@ union bpf_attr { · 303 unmodified lines
18461868 __u32 cnt;
18471869 __u32 flags;
18481870 __u32 pid;
1871+ __u32 path_fd;
18491872 } uprobe_multi;
18501873 struct {
18511874 union {
@@ -1861,6 +1884,11 @@ union bpf_attr { · 9 unmodified lines
18611884 };
18621885 __u64 expected_revision;
18631886 } cgroup;
1887+ struct {
1888+ __aligned_u64 ids;
1889+ __aligned_u64 cookies;
1890+ __u32 cnt;
1891+ } tracing_multi;
18641892 };
18651893 } link_create;
18661894
@@ -6698,6 +6726,7 @@ struct bpf_prog_info { · 4831 unmodified lines
66986726 __u32 verified_insns;
66996727 __u32 attach_btf_obj_id;
67006728 __u32 attach_btf_id;
6729+ __u32 :32;
67016730 } __attribute__((aligned(8)));
67026731
67036732 struct bpf_map_info {
@@ -6719,6 +6748,7 @@ struct bpf_map_info { · 15 unmodified lines
67196748 __u64 map_extra;
67206749 __aligned_u64 hash;
67216750 __u32 hash_size;
6751+ __u32 :32;
67226752 } __attribute__((aligned(8)));
67236753
67246754 struct bpf_btf_info {
include/uapi/linux/btf.h+14−12
@@ -33,20 +33,22 @@ struct btf_header { · 32 unmodified lines
3333 __u32 layout_len; /* length of layout section */
3434 };
3535
36−/* Max # of type identifier */
37−#define BTF_MAX_TYPE 0x000fffff
38−/* Max offset into the string section */
39−#define BTF_MAX_NAME_OFFSET 0x00ffffff
40−/* Max # of struct/union/enum members or func args */
41−#define BTF_MAX_VLEN 0xffff
36+enum btf_max {
37+ /* Max possible kind */
38+ BTF_MAX_KIND = 0x0000007f,
39+ /* Max # of type identifier */
40+ BTF_MAX_TYPE = 0x000fffff,
41+ /* Max offset into the string section */
42+ BTF_MAX_NAME_OFFSET = 0x00ffffff,
43+ /* Max # of struct/union/enum members or func args */
44+ BTF_MAX_VLEN = 0x00ffffff,
45+};
4246
4347 struct btf_type {
4448 __u32 name_off;
4549 /* "info" bits arrangement
46− * bits 0-15: vlen (e.g. # of struct's members)
47− * bits 16-23: unused
48− * bits 24-28: kind (e.g. int, ptr, array...etc)
49− * bits 29-30: unused
50+ * bits 0-23: vlen (e.g. # of struct's members)
51+ * bits 24-30: kind (e.g. int, ptr, array...etc)
5052 * bit 31: kind_flag, currently used by
5153 * struct, union, enum, fwd, enum64,
5254 * decl_tag and type_tag
@@ -65,8 +67,8 @@ struct btf_type { · 12 unmodified lines
6567 };
6668 };
6769
68−#define BTF_INFO_KIND(info) (((info) >> 24) & 0x1f)
69−#define BTF_INFO_VLEN(info) ((info) & 0xffff)
70+#define BTF_INFO_KIND(info) (((info) >> 24) & 0x7f)
71+#define BTF_INFO_VLEN(info) ((info) & 0xffffff)
7072 #define BTF_INFO_KFLAG(info) ((info) >> 31)
7173
7274 enum {