CVE-2026-98038: bpf: Keep refcount_acquire nullable for borrowed RCU kptrs
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
bpf: Keep refcount_acquire nullable for borrowed RCU kptrs
bpf_refcount_acquire() is fallible for a borrowed reference because the object may have reached a zero refcount. The verifier therefore keeps KF_RET_NULL on the return value unless the argument is an owning reference.
An RCU-protected load of a local kptr is marked MEM_ALLOC, but it only receives NON_OWN_REF when the pointee contains a graph node. A refcounted object without a graph node consequently looks like an owning reference even though the loaded register has no acquired reference state. If the program drops the last real reference while remaining in the RCU critical section, refcount_inc_not_zero() returns NULL while the verifier treats the result as non-NULL.
Only classify the argument as owning when it is backed by a verifier-tracked reference. This retains the non-NULL return for pointers from bpf_obj_new(), bpf_kptr_xchg(), or an earlier successful acquisition, while requiring a NULL check for borrowed RCU kptrs.
[ kkd: Rewrote commit log ]
The Linux kernel CVE team has assigned CVE-2026-98038 to this issue.
Affected and fixed versions
===========================
Issue introduced in 6.8 with commit 1b12171533a9bb23cf6fba7262b479028b65e1e8 and fixed in 7.2.7 with commit 85074498228a2500ea8b8039c49cc1ab8ad5328f Issue introduced in 6.8 with commit 1b12171533a9bb23cf6fba7262b479028b65e1e8 and fixed in 7.3-rc2 with commit dc36739e5cc9f60485418a910b42bc95339218d2
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2026-98038
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
kernel/bpf/verifier.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/85074498228a2500ea8b8039c49cc1ab8ad5328f https://git.kernel.org/stable/c/dc36739e5cc9f60485418a910b42bc95339218d2