Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67AF115820C for ; Wed, 12 Mar 2025 09:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741772553; cv=none; b=VgbbYytczZo3MTTFmDVpKr0jNH0RJt451eRvP0rM9trk6tEKWa0IGWb6LCRj+OAE8J/iLyIKAVvZOme1HtVFKimHRtut6GIrklF+T2OMdrbCCH5DJ8RScIUpaJpEfqeQjrHvZe1OqxXDaplardvlF72abqe0iiBIZ6XfEblC+fA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741772553; c=relaxed/simple; bh=AdiegAqSnTVHZ6l0RNWjZ266i/U6prdXPG20fWWrqgs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Q5Z5PySLGrWN9Mq6xT7F2iQPqA5WtsSZcNEXuLUXkkvVKVtnVkvOpZFSXV4YjDM1VQyZzOtiIhL+bH+P+2KhtB2YvbrHAUVRZWzSeV33F3ex6TpT7+OOqTJuk0uPebLHgF68MMRCiwBO+jC8e6JwqJHfNao6VcvLILwtdlAeadM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wAaFbpuL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wAaFbpuL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 810A5C4CEE3; Wed, 12 Mar 2025 09:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741772552; bh=AdiegAqSnTVHZ6l0RNWjZ266i/U6prdXPG20fWWrqgs=; h=From:To:Cc:Subject:Date:Reply-to:From; b=wAaFbpuLWNPuz/Vyq0m1nivhTxlX3B8jn+M7LHEj1hytNju/LaU3CLHitGMGlKEDQ AtgMlWYAxX/DAU24eifq7orMVFUsL3YDjkw3jySQCKzvVWnVEKc5UIguDU6gbO4kvk BKfnSrzXWHI7EVobOva5qzR45nKr8+SVuDoJlKKM= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-21852: net: Add rx_skb of kfree_skb to raw_tp_null_args[]. Date: Wed, 12 Mar 2025 10:42:18 +0100 Message-ID: <2025031213-CVE-2025-21852-b942@gregkh> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3851; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=AdiegAqSnTVHZ6l0RNWjZ266i/U6prdXPG20fWWrqgs=; b=owGbwMvMwCRo6H6F97bub03G02pJDOkXw75ahZYniDXfyPLZ5yA9//TeV9/PMM2bwR+et/GHn WPE2+7cjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZiIbRvDPGOuc+VG7Atecd4M SHSWrprg99J7GcM8gy7pLpPHXw5pmZfbPt+vdpvd6csPAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: net: Add rx_skb of kfree_skb to raw_tp_null_args[]. Yan Zhai reported a BPF prog could trigger a null-ptr-deref [0] in trace_kfree_skb if the prog does not check if rx_sk is NULL. Commit c53795d48ee8 ("net: add rx_sk to trace_kfree_skb") added rx_sk to trace_kfree_skb, but rx_sk is optional and could be NULL. Let's add kfree_skb to raw_tp_null_args[] 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 BPF_PROG(drop, struct sk_buff *skb, void *location, @ kfree_skb_sk_null.bpf.c:21 0: (79) r3 = *(u64 *)(r1 +24) func 'kfree_skb' arg3 has btf_id 5253 type STRUCT 'sock' 1: R1=ctx() R3_w=trusted_ptr_or_null_sock(id=1) ; bpf_printk("sk: %d, %d\n", sk, sk->__sk_common.skc_family); @ kfree_skb_sk_null.bpf.c:24 1: (69) r4 = *(u16 *)(r3 +16) R3 invalid mem access 'trusted_ptr_or_null_' processed 2 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 -- END PROG LOAD LOG -- Note this fix requires commit 838a10bd2ebf ("bpf: Augment raw_tp arguments with PTR_MAYBE_NULL"). [0]: BUG: kernel NULL pointer dereference, address: 0000000000000010 PF: supervisor read access in kernel mode PF: error_code(0x0000) - not-present page PGD 0 P4D 0 PREEMPT SMP RIP: 0010:bpf_prog_5e21a6db8fcff1aa_drop+0x10/0x2d Call Trace: ? __die+0x1f/0x60 ? page_fault_oops+0x148/0x420 ? search_bpf_extables+0x5b/0x70 ? fixup_exception+0x27/0x2c0 ? exc_page_fault+0x75/0x170 ? asm_exc_page_fault+0x22/0x30 ? bpf_prog_5e21a6db8fcff1aa_drop+0x10/0x2d bpf_trace_run4+0x68/0xd0 ? unix_stream_connect+0x1f4/0x6f0 sk_skb_reason_drop+0x90/0x120 unix_stream_connect+0x1f4/0x6f0 __sys_connect+0x7f/0xb0 __x64_sys_connect+0x14/0x20 do_syscall_64+0x47/0xc30 entry_SYSCALL_64_after_hwframe+0x4b/0x53 The Linux kernel CVE team has assigned CVE-2025-21852 to this issue. Affected and fixed versions =========================== Issue introduced in 6.11 with commit c53795d48ee8f385c6a9e394651e7ee914baaeba and fixed in 6.12.17 with commit f579afacd0a66971fc8481f30d2d377e230a8342 Issue introduced in 6.11 with commit c53795d48ee8f385c6a9e394651e7ee914baaeba and fixed in 6.13.5 with commit 4dba79c1e7aad6620bbb707b6c4459380fd90860 Issue introduced in 6.11 with commit c53795d48ee8f385c6a9e394651e7ee914baaeba and fixed in 6.14-rc4 with commit 5da7e15fb5a12e78de974d8908f348e279922ce9 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-2025-21852 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/btf.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/f579afacd0a66971fc8481f30d2d377e230a8342 https://git.kernel.org/stable/c/4dba79c1e7aad6620bbb707b6c4459380fd90860 https://git.kernel.org/stable/c/5da7e15fb5a12e78de974d8908f348e279922ce9