CVE-2025-21852: net: Add rx_skb of kfree_skb to raw_tp_null_args[].
In the Linux kernel, the following vulnerability has been resolved:
net: Add rxskb of kfreeskb to rawtpnullargs[].
Yan Zhai reported a BPF prog could trigger a null-ptr-deref [0] in tracekfreeskb if the prog does not check if rxsk is NULL.
Commit c53795d48ee8 ("net: add rxsk to tracekfreeskb") added rxsk to tracekfreeskb, but rxsk is optional and could be NULL.
Let's add kfreeskb to rawtpnullargs[] to let the BPF verifier validate such a prog and prevent the issue.
Now we fail to load such a prog:
libbpf: prog 'drop': -- BEGIN PROG LOAD LOG -- 0: R1=ctx() R10=fp0 ; int BPFPROG(drop, struct skbuff skb, void location, @ kfreeskbsknull.bpf.c:21 0: (79) r3 = (u64 )(r1 +24) func 'kfreeskb' arg3 has btfid 5253 type STRUCT 'sock' 1: R1=ctx() R3w=trustedptrornullsock(id=1) ; bpfprintk("sk: %d, %d\n", sk, sk->skcommon.skcfamily); @ kfreeskbsknull.bpf.c:24 1: (69) r4 = (u16 )(r3 +16) R3 invalid mem access 'trustedptrornull' processed 2 insns (limit 1000000) maxstatesperinsn 0 totalstates 0 peakstates 0 markread 0 -- END PROG LOAD LOG --
Note this fix requires commit 838a10bd2ebf ("bpf: Augment rawtp arguments with PTRMAYBENULL").
[0]: BUG: kernel NULL pointer dereference, address: 0000000000000010 PF: supervisor read access in kernel mode PF: errorcode(0x0000) - not-present page PGD 0 P4D 0 PREEMPT SMP RIP: 0010:bpfprog5e21a6db8fcff1aadrop+0x10/0x2d Call Trace: <TASK> ? die+0x1f/0x60 ? pagefaultoops+0x148/0x420 ? searchbpfextables+0x5b/0x70 ? fixupexception+0x27/0x2c0 ? excpagefault+0x75/0x170 ? asmexcpagefault+0x22/0x30 ? bpfprog5e21a6db8fcff1aadrop+0x10/0x2d bpftracerun4+0x68/0xd0 ? unixstreamconnect+0x1f4/0x6f0 skskbreasondrop+0x90/0x120 unixstreamconnect+0x1f4/0x6f0 sysconnect+0x7f/0xb0 x64sysconnect+0x14/0x20 dosyscall64+0x47/0xc30 entrySYSCALL64afterhwframe+0x4b/0x53
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch 838a10bd2ebf
Event History
Frequently Asked Questions
What is the severity of CVE-2025-21852?
CVE-2025-21852 has been classified as a medium severity vulnerability in the Linux kernel.
How do I fix CVE-2025-21852?
To address CVE-2025-21852, update your Linux kernel to the latest version where the vulnerability has been patched.
What systems are affected by CVE-2025-21852?
CVE-2025-21852 affects various versions of the Linux kernel where the null pointer dereference occurs in BPF programs.
What is the impact of CVE-2025-21852?
The impact of CVE-2025-21852 includes potential denial of service due to the null pointer dereference in the kernel.
Who reported CVE-2025-21852?
CVE-2025-21852 was reported by Yan Zhai regarding a possible null pointer dereference in trace_kfree_skb.