CVE-2026-143362: bpf: Require prog fd or capability for cgroup detach
In the Linux kernel, the following vulnerability has been resolved:
bpf: Require prog fd or capability for cgroup detach
Since the commit below a cgroup prog detach does not require CAPNETADMIN. The fd of the attached prog gives the permission instead. But the detach requires this fd only with BPFFALLOWMULTI. Without this flag a cgroup has only one prog per attach type. Then finddetachentry() returns this prog and does not compare it with the prog of the caller. Thus the kernel detaches this prog for a caller with neither the fd nor a capability.
Compare the two progs. If they are different, require CAPNETADMIN or CAPSYSADMIN in the initial user namespace. The error is -EPERM. A detach from tcx or netkit without a prog fd already requires these capabilities. With BPFFALLOWMULTI nothing changes.
Without these capabilities, a caller of bpfprogdetach() of libbpf must now use bpfprogdetach2() with the fd of the attached prog.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Operational
For cgroup BPF detach without BPF_F_ALLOW_MULTI, use bpf_prog_detach2() with the file descriptor of the attached program; if the caller's program differs from the attached program, require CAP_NET_ADMIN or CAP_SYS_ADMIN in the initial user namespace.
Event History
Frequently Asked Questions
Which cgroup BPF attachment scenarios are affected?
The issue applies when BPF_F_ALLOW_MULTI is not used, so the cgroup has a single program for the relevant attach type. Attachments using BPF_F_ALLOW_MULTI are unchanged.
What could a caller do without the required permissions?
A caller could detach the program returned by the kernel without possessing that program's file descriptor and without CAP_NET_ADMIN or CAP_SYS_ADMIN in the initial user namespace. The corrected behavior rejects a detach involving a different program with -EPERM unless one of those capabilities is present.
What changes are needed for libbpf callers after applying the fix?
A caller without the required capabilities must use bpf_prog_detach2() and provide the file descriptor of the attached program. Calls to bpf_prog_detach() without that descriptor can no longer detach the program in this case.