WSL2-Linux-Kernel/tools/lib/bpf
Andrii Nakryiko 71754ee427 libbpf: fix offsetof() and container_of() to work with CO-RE
[ Upstream commit bdeeed3498 ]

It seems like __builtin_offset() doesn't preserve CO-RE field
relocations properly. So if offsetof() macro is defined through
__builtin_offset(), CO-RE-enabled BPF code using container_of() will be
subtly and silently broken.

To avoid this problem, redefine offsetof() and container_of() in the
form that works with CO-RE relocations more reliably.

Fixes: 5fbc220862 ("tools/libpf: Add offsetof/container_of macro in bpf_helpers.h")
Reported-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20230509065502.2306180-1-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-07-23 13:46:49 +02:00
..
.gitignore
Build
Makefile libbpf: Fix build issue with llvm-readelf 2022-04-13 20:59:03 +02:00
bpf.c libbpf: Fix lookup_and_delete_elem_flags error reporting 2021-11-18 19:17:09 +01:00
bpf.h libbpf: Avoid enum forward-declarations in public API in C++ mode 2022-12-31 13:14:43 +01:00
bpf_core_read.h libbpf: Fix endianness detection in BPF_CORE_READ_BITFIELD_PROBED() 2021-11-18 19:16:41 +01:00
bpf_endian.h
bpf_gen_internal.h
bpf_helpers.h libbpf: fix offsetof() and container_of() to work with CO-RE 2023-07-23 13:46:49 +02:00
bpf_prog_linfo.c
bpf_tracing.h
btf.c libbpf: Fix btf__align_of() by taking into account field offsets 2023-03-10 09:39:06 +01:00
btf.h libbpf: Fix potential misaligned memory access in btf_ext__new() 2022-01-27 11:03:16 +01:00
btf_dump.c libbpf: btf_dump_type_data_check_overflow needs to consider BTF_MEMBER_BITFIELD_SIZE 2023-07-23 13:46:49 +02:00
gen_loader.c libbpf: fix an snprintf() overflow check 2022-08-17 14:23:32 +02:00
hashmap.c
hashmap.h
libbpf.c libbpf: Fix null-pointer dereference in find_prog_by_sec_insn() 2022-12-31 13:14:06 +01:00
libbpf.h libbpf: Add uprobe ref counter offset support for USDT semaphores 2021-08-17 00:45:08 +02:00
libbpf.map libbpf: Add bpf_cookie to perf_event, kprobe, uprobe, and tp attach APIs 2021-08-17 00:45:08 +02:00
libbpf.pc.template
libbpf_common.h
libbpf_errno.c
libbpf_internal.h libbpf: Add bpf_cookie support to bpf_link_create() API 2021-08-17 00:45:08 +02:00
libbpf_legacy.h
libbpf_probes.c libbpf: Use page size as max_entries when probing ring buffer map 2022-12-19 12:36:41 +01:00
linker.c libbpf: Fix using invalidated memory in bpf_linker 2022-01-27 11:03:16 +01:00
netlink.c libbpf: Fix memleak in libbpf_netlink_recv() 2022-04-08 14:23:31 +02:00
nlattr.c libbpf: Fix alen calculation in libbpf_nla_dump_errormsg() 2023-03-10 09:39:16 +01:00
nlattr.h
relo_core.c
relo_core.h
ringbuf.c libbpf: Handle size overflow for ringbuf mmap 2022-12-08 11:28:39 +01:00
skel_internal.h libbpf: Fix skel_internal.h to set errno on loader retval < 0 2021-11-18 19:16:27 +01:00
str_error.c
str_error.h
strset.c libbpf: Fix memory leak in strset 2021-10-01 22:54:38 +02:00
strset.h
xsk.c selftests/xsk: Avoid use-after-free on ctx 2022-10-26 12:34:41 +02:00
xsk.h