Not yet analysed by NVD. Matched on the vendor's record; this may change when NVD has analysed it.
Reach linux · 2 builds in 1 of 4 releases
full reviewcross-check✓ a member decided
Description · NVD
bpf: Hold map BTF for the memory allocator destructor record
bpf_ma_set_dtor() duplicates map->record so that the bpf_mem_alloc destructor can release the special fields of hash and rhash map elements once the allocator frees them for good. btf_record_dup() only acquires references on kernel and module BTF. Fields whose types live in the map BTF keep pointing into it: a kptr to a local type refers to map->btf, and a list_head or rb_root field carries a value_rec owned by the struct meta table of map->btf.
That borrowed state can outlive the map. When RCU callbacks are still in flight, bpf_mem_alloc_destroy() copies the allocator and defers the final drain, together with the destructor context, to a workqueue. bpf_map_free() then frees map->record and drops the map's BTF reference as soon as map_free() returns. Once the program that loaded the BTF is gone as well, the BTF is freed while the worker still uses the duplicate. The worker dereferences it through btf_is_kernel() and btf_find_struct_meta() in bpf_obj_free_fields() when destroying elements that were freed under RCU, and through btf_is_kernel() in btf_record_free() when releasing the context itself:
BUG: KASAN: slab-use-after-free in btf_is_kernel+0x19/0x30kernel log · 23 lines
BUG: KASAN: slab-use-after-free in btf_is_kernel+0x19/0x30 Read of size 1 at addr ffff88811505dce8 by task kworker/u16:2/50 Workqueue: events_unbound free_mem_alloc_deferred Call Trace: btf_is_kernel+0x19/0x30 btf_record_free+0xc7/0xf0 htab_dtor_ctx_free+0x1a/0x30 free_mem_alloc_no_barrier+0x39/0x230 free_mem_alloc_deferred+0x2a/0x40 process_scheduled_works+0x5ce/0x9d0 worker_thread+0x42a/0x5e0 kthread+0x1f5/0x230 ret_from_fork+0x1dd/0x390 ret_from_fork_asm+0x1a/0x30 Allocated by task 358: __kmalloc_cache_noprof+0x287/0x510 btf_new_fd+0xf7/0x3d0 __sys_bpf+0x487/0x840 Freed by task 0: kfree+0x186/0x560 rcu_core+0x6f6/0xd40
Freeing a map that still holds more elements than the allocator's high watermark is enough to get there, because the bulk free during teardown queues the RCU callback that makes bpf_mem_alloc_destroy() defer. Non-preallocated hash maps and resizable hash maps both register the destructor and are affected alike.
Keep one reference on the map BTF in the destructor context. Every non-kernel pointer in the duplicated record is either map->btf or memory owned by it, so a single reference covers kptrs, list heads, and rb roots, and mirrors what bpf_map_meta_alloc() does for the duplicated record of an inner map. Release it only after the duplicated record has been freed: the worker is preemptible and not in an RCU read-side critical section, so dropping the last reference first would let the BTF be freed while btf_record_free() still reads its fields.
Published 2026-10-18NVD
The vulnerable code is in this build and the fix is not: htab_set_dtor() in kernel/bpf/hashtab.c duplicates map->record for the allocator destructor without holding a reference on the map BTF, and no applied patch touches BPF.
Reaching it needs a process with CAP_BPF or root calling bpf() directly to load BTF and create a non-preallocated hash map with special fields. Nothing in the image does that: bpftool, libbpf, bpftrace and elfutils are not selected, so iproute2 is built without its BPF loader, and nothing in confd or the rootfs overlay loads BPF. No YANG node, CLI command or web UI function creates BPF maps, and it is not reachable from a network interface.
The kernel is also built without CONFIG_DEBUG_INFO_BTF. In this tree that makes kptr fields fail to parse at map creation, which closes the kptr route to the dangling BTF pointer. The list/rb-root route only dereferences BTF-owned memory for non-empty lists, which need the bpf_obj_new kfuncs; I believe those are unusable without vmlinux BTF but did not confirm it in the source.
Evidence 12
The destructor context holds only `btf_record_dup(htab->map.record)` and a key size. There is no `btf_get()` on `map->btf` and no `btf_put()` in the context free, so the fix is absent.
output/build/linux-6.18.60/kernel/bpf/hashtab.c:506-539 (htab_dtor_ctx_free, htab_set_dtor)
The destructor is registered for every non-preallocated hash or per-CPU hash map whose value has a BTF record.
output/build/linux-6.18.60/kernel/bpf/hashtab.c:541-559 (htab_map_check_btf)
The deferred allocator teardown calls `dtor_ctx_free` after callbacks finish, which is the worker path in the CVE trace.
output/build/linux-6.18.60/kernel/bpf/memalloc.c:693-695
`hashtab.o`, `memalloc.o` and `btf.o` are guarded by `CONFIG_BPF_SYSCALL` and were all built.
output/build/linux-6.18.60/kernel/bpf/Makefile:11,17 and output/objects.txt:21950,21937,21909
`CONFIG_BPF_SYSCALL=y` and `CONFIG_BPF_UNPRIV_DEFAULT_OFF=y`: the `bpf()` syscall exists but unprivileged use is off by default.
output/build/linux-6.18.60/.config:118,122
Creating a map with special BTF fields requires `bpf_token_capable(token, CAP_BPF)`, so the path is privileged-only whatever the sysctl says.
output/build/linux-6.18.60/kernel/bpf/syscall.c:1276
`CONFIG_DEBUG_INFO_BTF` is absent and `CONFIG_PAHOLE_VERSION=0`: there is no vmlinux BTF in this kernel.
output/build/linux-6.18.60/.config:25,4724-4729
Without `CONFIG_DEBUG_INFO_BTF`, `bpf_get_btf_vmlinux()` returns NULL, `bpf_find_btf_id()` returns `-EINVAL`, and `btf_parse_kptr()` fails rather than taking the `-ENOENT` local-type branch. Maps with kptr fields cannot be created.
output/build/linux-6.18.60/kernel/bpf/verifier.c:24692-24713 and kernel/bpf/btf.c:567-577, 3826-3841
The dangling BTF is only read for kptr fields (`btf_is_kernel`, `btf_find_struct_meta`) or when draining a non-empty list/rb-root (`graph_root.value_rec`). Spin lock, timer and workqueue fields never touch it.
output/build/linux-6.18.60/kernel/bpf/syscall.c:666-701, 842-871 and kernel/bpf/helpers.c:2141-2156
`BR2_PACKAGE_BPFTOOL`, `BR2_PACKAGE_BPFTRACE`, `BR2_PACKAGE_LIBBPF`, `BR2_PACKAGE_ELFUTILS` and `BR2_PACKAGE_LINUX_TOOLS_BPFTOOL` are not set: no BPF loader ships in the image.
output/.config:618,620,659,2855,4467
`iproute2` only gets ELF/libbpf loading when `elfutils`/`libbpf` are selected; here it is built with `--libbpf_force off`.
buildroot/package/iproute2/iproute2.mk:16,42-45
The only management-interface route to `CAP_BPF` is the container `privileged` leaf and `capabilities` list. They grant privilege to operator-supplied container code; they do not themselves use BPF maps.
src/confd/yang/confd/infix-containers.yang:288,375-385
Version and patches
I could not consult the upstream fix commits (ab39974240a0, b506f5699e14) or the CNA affected range from this tree, and NVD has not analysed the record yet. The decision rests on the source: 6.18.60 has the hash-map destructor record without the BTF reference, so it is the vulnerable form.
None of the 139 applied patches mentions BPF or BTF: a search of output/build/linux-6.18.60/.applied_patches_list and of patches/linux for either word returned nothing. The fixed stable version is not known from the tree.
Recommendation
No urgent backport is needed. Document the finding as not exposed: privileged-only local bpf() use, no BPF loader in the image, no vmlinux BTF. Pick up the fix through the next routine 6.18.y stable bump that contains it.
Re-evaluate if CONFIG_DEBUG_INFO_BTF, libbpf or bpftool is ever enabled, or if privileged containers running untrusted workloads are part of the threat model.
Open questions
- –The upstream affected range and the first fixed 6.18.y release could not be checked offline.
- –I did not trace in the verifier that the
bpf_obj_newand list/rb-tree kfuncs are unusable without vmlinux BTF. If they were usable, a root process could still hit the list/rb-root variant. That would not change the verdict, since it still needs root-levelbpf()access from outside the management interfaces.
- –An operator can configure a container with
privilegedor added capabilities ininfix-containers.yang. Code inside such a container could callbpf(). I treated this as stepping outside the product (operator-supplied root code), not as a management-interface enablement of the vulnerable feature.
- –Only the
x86_64config was reviewed.board/aarch64/linux_defconfigandboard/riscv64/linux_defconfigalso mention BPF and were not checked.
Members of Kernel Kit decide. Sign in if you are one.