OpenCloudOS-Kernel/tools/include/uapi/linux
Andrii Nakryiko 82e6b1eee6 bpf: Allow to specify user-provided bpf_cookie for BPF perf links
Add ability for users to specify custom u64 value (bpf_cookie) when creating
BPF link for perf_event-backed BPF programs (kprobe/uprobe, perf_event,
tracepoints).

This is useful for cases when the same BPF program is used for attaching and
processing invocation of different tracepoints/kprobes/uprobes in a generic
fashion, but such that each invocation is distinguished from each other (e.g.,
BPF program can look up additional information associated with a specific
kernel function without having to rely on function IP lookups). This enables
new use cases to be implemented simply and efficiently that previously were
possible only through code generation (and thus multiple instances of almost
identical BPF program) or compilation at runtime (BCC-style) on target hosts
(even more expensive resource-wise). For uprobes it is not even possible in
some cases to know function IP before hand (e.g., when attaching to shared
library without PID filtering, in which case base load address is not known
for a library).

This is done by storing u64 bpf_cookie in struct bpf_prog_array_item,
corresponding to each attached and run BPF program. Given cgroup BPF programs
already use two 8-byte pointers for their needs and cgroup BPF programs don't
have (yet?) support for bpf_cookie, reuse that space through union of
cgroup_storage and new bpf_cookie field.

Make it available to kprobe/tracepoint BPF programs through bpf_trace_run_ctx.
This is set by BPF_PROG_RUN_ARRAY, used by kprobe/uprobe/tracepoint BPF
program execution code, which luckily is now also split from
BPF_PROG_RUN_ARRAY_CG. This run context will be utilized by a new BPF helper
giving access to this user-provided cookie value from inside a BPF program.
Generic perf_event BPF programs will access this value from perf_event itself
through passed in BPF program context.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/bpf/20210815070609.987780-6-andrii@kernel.org
2021-08-17 00:45:07 +02:00
..
tc_act net: Move all TC actions identifiers to one place 2019-02-10 09:28:43 -08:00
bpf.h bpf: Allow to specify user-provided bpf_cookie for BPF perf links 2021-08-17 00:45:07 +02:00
bpf_common.h bpf: Sync kernel ABI header with tooling header for bpf_common.h 2018-02-09 00:24:38 +01:00
bpf_perf_event.h tools, headers: Sync struct bpf_perf_event_data 2021-01-26 00:15:03 +01:00
btf.h bpf: Add BTF_KIND_FLOAT to uapi 2021-03-04 17:58:15 -08:00
const.h tools headers UAPI: Sync linux/const.h with the kernel headers 2020-12-18 17:32:28 -03:00
erspan.h tools, include: Grab a copy of linux/erspan.h 2018-04-30 17:56:24 +02:00
ethtool.h libbpf: add support for using AF_XDP sockets 2019-02-25 23:21:42 +01:00
fadvise.h tools headers uapi: Grab a copy of fadvise.h 2018-12-18 16:17:40 -03:00
fcntl.h tools headers API: Update faccessat2 affected files 2020-06-09 12:40:03 -03:00
filter.h tools: bpf: Use local copy of headers including uapi/linux/filter.h 2020-07-21 10:50:35 +01:00
fs.h tools headers UAPI: Sync linux/fs.h with the kernel sources 2021-05-21 16:00:31 -03:00
fscrypt.h tools headers UAPI: Sync linux/fscrypt.h with the kernel sources 2020-12-18 17:32:28 -03:00
hw_breakpoint.h tools/headers: Synchronize kernel ABI headers 2017-11-04 09:27:46 +01:00
if_link.h bonding: add new option lacp_active 2021-08-03 11:50:22 +01:00
if_tun.h selftests/bpf: fix compilation error for flow_dissector.c 2019-05-29 15:15:07 +02:00
if_xdp.h xsk: Add new statistics 2020-07-13 15:32:56 -07:00
in.h tools headers UAPI: Sync linux/in.h copy with the kernel sources 2021-06-19 10:15:22 -03:00
kcmp.h tools headers: Synchronize kernel ABI headers wrt SPDX tags 2017-11-28 14:29:20 -03:00
kvm.h tools headers UAPI: Sync linux/kvm.h with the kernel sources 2021-07-01 16:14:37 -03:00
lirc.h media: rc: rcmm decoder and encoder 2019-02-18 15:39:49 -05:00
mman.h tools UAPI: Update copy of linux/mman.h from the kernel sources 2020-11-03 08:36:51 -03:00
mount.h tools include UAPI: Update linux/mount.h copy 2021-07-01 16:14:36 -03:00
netlink.h net: netlink: rename NETLINK_DUMP_STRICT_CHK -> NETLINK_GET_STRICT_CHK 2018-12-14 11:44:31 -08:00
openat2.h tools headers UAPI: Sync openat2.h with the kernel sources 2021-03-06 16:54:22 -03:00
perf_event.h tools headers UAPI: Sync linux/perf_event.h with the kernel sources 2021-05-21 16:03:08 -03:00
pkt_cls.h net: sched: remove NET_CLS_IND config option 2019-06-15 14:06:13 -07:00
pkt_sched.h sch_htb: Hierarchical QoS hardware offload 2021-01-22 20:41:29 -08:00
prctl.h sched: prctl() core-scheduling interface 2021-05-12 11:43:31 +02:00
sched.h tools headers UAPI: Sync sched.h with the kernel 2020-04-14 09:01:08 -03:00
seg6.h selftests/bpf: missing headers test_lwt_seg6local 2018-05-28 17:41:00 +02:00
seg6_local.h selftests/bpf: missing headers test_lwt_seg6local 2018-05-28 17:41:00 +02:00
stat.h tools headers UAPI: Sync linux/stat.h with the kernel sources 2020-12-17 14:40:24 -03:00
tcp.h bpf: Remove extra lock_sock for TCP_ZEROCOPY_RECEIVE 2021-01-20 14:23:00 -08:00
tls.h bpf, tls: add tls header to tools infrastructure 2018-10-16 08:10:01 -07:00
types.h tools/bpf: Move linux/types.h for selftests and bpftool 2020-03-13 20:56:34 +01:00
usbdevice_fs.h tools headers uapi: Sync linux/usbdevice_fs.h with the kernel sources 2019-09-30 17:29:02 -03:00
vhost.h tools kvm headers: Update KVM headers from the kernel sources 2020-11-03 08:46:30 -03:00