2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/tools/lib/bpf
Adin Scannell fa6f092cc0 libbpf: Fix possible use-after-free for externs
The `name` field in `obj->externs` points into the BTF data at initial
open time. However, some functions may invalidate this after opening and
before loading (e.g. `bpf_map__set_value_size`), which results in
pointers into freed memory and undefined behavior.

The simplest solution is to simply `strdup` these strings, similar to
the `essent_name`, and free them at the same time.

In order to test this path, the `global_map_resize` BPF selftest is
modified slightly to ensure the presence of an extern, which causes this
test to fail prior to the fix. Given there isn't an obvious API or error
to test against, I opted to add this to the existing test as an aspect
of the resizing feature rather than duplicate the test.

Fixes: 9d0a23313b ("libbpf: Add capability for resizing datasec maps")
Signed-off-by: Adin Scannell <amscanne@meta.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250625050215.2777374-1-amscanne@meta.com
2025-06-25 12:28:58 -07:00
..
.gitignore tools build: Correct bpf fixdep dependencies 2024-08-05 12:19:48 -03:00
bpf_core_read.h bpf: Fix uninitialized values in BPF_{CORE,PROBE}_READ 2025-05-05 14:20:28 -07:00
bpf_endian.h libbpf: Make bpf_endian co-exist with vmlinux.h 2020-07-01 09:06:12 +02:00
bpf_gen_internal.h libbpf: Support creating light skeleton of either endianness 2024-10-03 17:47:36 -07:00
bpf_helpers.h libbpf: Add likely/unlikely macros and use them in selftests 2025-04-04 08:53:24 -07:00
bpf_prog_linfo.c libbpf: Streamline error reporting for high-level APIs 2021-05-25 17:32:35 -07:00
bpf_tracing.h libbpf: Fix some typos in comments 2024-09-09 16:05:40 -07:00
bpf.c libbpf: Pass BPF token from find_prog_btf_id to BPF_BTF_GET_FD_BY_ID 2025-03-17 13:45:12 -07:00
bpf.h libbpf: Pass BPF token from find_prog_btf_id to BPF_BTF_GET_FD_BY_ID 2025-03-17 13:45:12 -07:00
btf_dump.c libbpf: Fix null pointer dereference in btf_dump__free on allocation failure 2025-06-23 11:13:40 -07:00
btf_iter.c libbpf,bpf: Share BTF relocate-related code with kernel 2024-06-21 14:45:07 -07:00
btf_relocate.c libbpf: Fix incorrect traversal end type ID when marking BTF_IS_EMBEDDED 2025-01-16 15:34:18 -08:00
btf.c libbpf: Handle unsupported mmap-based /sys/kernel/btf/vmlinux correctly 2025-06-06 14:07:07 -07:00
btf.h libbpf: Introduce kflag for type_tags and decl_tags in BTF 2025-02-05 16:17:59 -08:00
Build libbpf: Split field iter code into its own file kernel 2024-06-21 14:45:07 -07:00
elf.c libbpf: Stringify errno in log messages in the remaining code 2024-11-11 20:29:45 -08:00
features.c libbpf: Stringify errno in log messages in the remaining code 2024-11-11 20:29:45 -08:00
gen_loader.c libbpf: Stringify errno in log messages in the remaining code 2024-11-11 20:29:45 -08:00
hashmap.c libbpf: Hashmap interface update to allow both long and void* keys/values 2022-11-09 20:45:14 -08:00
hashmap.h libbpf: Fix possible compiler warnings in hashmap 2024-10-11 12:36:59 -07:00
libbpf_common.h libbpf: Fix potential uninitialized tail padding with LIBBPF_OPTS_RESET 2023-11-09 19:07:51 -08:00
libbpf_errno.c libbpf: Optimized return value in libbpf_strerror when errno is libbpf errno 2022-12-14 18:39:33 +01:00
libbpf_internal.h libbpf: Fix implicit memfd_create() for bionic 2025-04-04 08:52:37 -07:00
libbpf_legacy.h libbpf: Fix some typos in comments 2024-09-09 16:05:40 -07:00
libbpf_probes.c bpf: improve error message for unsupported helper 2024-03-28 18:30:53 -07:00
libbpf_version.h libbpf: start v1.6 development cycle 2024-10-29 13:42:52 -07:00
libbpf.c libbpf: Fix possible use-after-free for externs 2025-06-25 12:28:58 -07:00
libbpf.h bpf-next-6.16 2025-05-28 15:52:42 -07:00
libbpf.map libbpf: Add getters for BTF.ext func and line info 2025-04-09 16:16:56 -07:00
libbpf.pc.template libbpf: Add zlib as a dependency in pkg-config template 2019-12-16 14:55:29 -08:00
linker.c libbpf: Use proper errno value in linker 2025-04-30 09:04:20 -07:00
Makefile tools: Remove redundant quiet setup 2025-02-18 16:27:43 -03:00
netlink.c libbpf: Support creating and destroying qdisc 2025-04-17 10:54:41 -07:00
nlattr.c libbpf: Use proper errno value in nlattr 2025-05-12 15:22:54 -07:00
nlattr.h libbpf: add API to get XDP/XSK supported features 2023-02-02 20:48:24 -08:00
relo_core.c libbpf: fix LDX/STX/ST CO-RE relocation size adjustment logic 2025-02-14 19:58:05 -08:00
relo_core.h bpf, libbpf: Add type match support 2022-07-05 21:14:25 -07:00
ringbuf.c libbpf: Stringify errno in log messages in the remaining code 2024-11-11 20:29:45 -08:00
skel_internal.h libbpf: Support creating light skeleton of either endianness 2024-10-03 17:47:36 -07:00
str_error.c libbpf: Add namespace for errstr making it libbpf_errstr 2025-03-21 13:44:54 -07:00
str_error.h libbpf: Add namespace for errstr making it libbpf_errstr 2025-03-21 13:44:54 -07:00
strset.c libbpf: Hashmap interface update to allow both long and void* keys/values 2022-11-09 20:45:14 -08:00
strset.h libbpf: Extract internal set-of-strings datastructure APIs 2021-03-18 16:14:22 -07:00
usdt.bpf.h libbpf: Implement bpf_usdt_arg_size BPF function 2025-02-26 08:59:44 -08:00
usdt.c libbpf: don't adjust USDT semaphore address if .stapsdt.base addr is missing 2024-12-02 08:41:17 -08:00
zip.c libbpf: Remove unneeded semicolon 2024-10-03 17:47:35 -07:00
zip.h libbpf: Implement basic zip archive parsing support 2023-03-01 16:05:34 -08:00