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 BF9E52701B6 for ; Wed, 1 Oct 2025 07:48:00 +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=1759304880; cv=none; b=UEMcNPLi20T3Uy/mCgMd2OhLu82cFA2GcFcI/yHAKyLLhXJuKnjPiAoa+cFA5t2iDd2ANZatELlaHmY2bNbTb9Qp9WQOeUEqz5NjC7Lu2uH+dzFqL2IvcBegrQFiWLqquYTwXTsG0xMDHlJJd6wLS+ozDnOr18eum7bKgeBMAeI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759304880; c=relaxed/simple; bh=7aNLkEElTfDDoKr53kNSIaFjGJiWNUc7mj8bSzpcjC4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KswVXUTvWOiiT1mPRZGPE4q1Xtnmz5ljCPzwBSORBEHm8p0DpPiPjlfehBS21tFO+62P2Fmu7OjfyhBJN64Jb35a5xH1pewFf2G3aB+JmL5MgCtsZbiBDhUVETAEC0FeRwwF/JKqEmnnhbPrnIgp7CC5wlethN0Dj6sMGNlpi6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ekSgmBPG; 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="ekSgmBPG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13E83C4CEF4; Wed, 1 Oct 2025 07:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1759304880; bh=7aNLkEElTfDDoKr53kNSIaFjGJiWNUc7mj8bSzpcjC4=; h=From:To:Cc:Subject:Date:Reply-to:From; b=ekSgmBPG4P070OT8fLRly+S4nWMh5E1HCyF/ohW3Z6nYbeetkQ97hl+vNfmfbel+p bDXORlfkuvTaQSoTY6+vYw3PRK4Otgk8En7JK0lVftiiu2z6OSoOgIlkt84idLOUvA lIW98AG7gj/vQLwidh/G8b+niVnJKN04ZQHk2nh4= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-39913: tcp_bpf: Call sk_msg_free() when tcp_bpf_send_verdict() fails to allocate psock->cork. Date: Wed, 1 Oct 2025 09:47:18 +0200 Message-ID: <2025100111-CVE-2025-39913-f166@gregkh> X-Mailer: git-send-email 2.51.0 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=5156; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=N3OGaxVdHEKAjEq/z+ReFwimixql77UWyB04J91Xnk0=; b=owGbwMvMwCRo6H6F97bub03G02pJDBl37tRfjHvQ/+PtuX3d8gr7md+5bDyRsO1PsfUB83fPM k8qzl05tyOWhUGQiUFWTJHlyzaeo/srDil6GdqehpnDygQyhIGLUwAmsq2cYcGcNccONPAd033T 9efjN+5Z91Z9OtrCsKCpZEbV9mKm2PVMKbIrr302nc/blAgA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: tcp_bpf: Call sk_msg_free() when tcp_bpf_send_verdict() fails to allocate psock->cork. syzbot reported the splat below. [0] The repro does the following: 1. Load a sk_msg prog that calls bpf_msg_cork_bytes(msg, cork_bytes) 2. Attach the prog to a SOCKMAP 3. Add a socket to the SOCKMAP 4. Activate fault injection 5. Send data less than cork_bytes At 5., the data is carried over to the next sendmsg() as it is smaller than the cork_bytes specified by bpf_msg_cork_bytes(). Then, tcp_bpf_send_verdict() tries to allocate psock->cork to hold the data, but this fails silently due to fault injection + __GFP_NOWARN. If the allocation fails, we need to revert the sk->sk_forward_alloc change done by sk_msg_alloc(). Let's call sk_msg_free() when tcp_bpf_send_verdict fails to allocate psock->cork. The "*copied" also needs to be updated such that a proper error can be returned to the caller, sendmsg. It fails to allocate psock->cork. Nothing has been corked so far, so this patch simply sets "*copied" to 0. [0]: WARNING: net/ipv4/af_inet.c:156 at inet_sock_destruct+0x623/0x730 net/ipv4/af_inet.c:156, CPU#1: syz-executor/5983 Modules linked in: CPU: 1 UID: 0 PID: 5983 Comm: syz-executor Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025 RIP: 0010:inet_sock_destruct+0x623/0x730 net/ipv4/af_inet.c:156 Code: 0f 0b 90 e9 62 fe ff ff e8 7a db b5 f7 90 0f 0b 90 e9 95 fe ff ff e8 6c db b5 f7 90 0f 0b 90 e9 bb fe ff ff e8 5e db b5 f7 90 <0f> 0b 90 e9 e1 fe ff ff 89 f9 80 e1 07 80 c1 03 38 c1 0f 8c 9f fc RSP: 0018:ffffc90000a08b48 EFLAGS: 00010246 RAX: ffffffff8a09d0b2 RBX: dffffc0000000000 RCX: ffff888024a23c80 RDX: 0000000000000100 RSI: 0000000000000fff RDI: 0000000000000000 RBP: 0000000000000fff R08: ffff88807e07c627 R09: 1ffff1100fc0f8c4 R10: dffffc0000000000 R11: ffffed100fc0f8c5 R12: ffff88807e07c380 R13: dffffc0000000000 R14: ffff88807e07c60c R15: 1ffff1100fc0f872 FS: 00005555604c4500(0000) GS:ffff888125af1000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00005555604df5c8 CR3: 0000000032b06000 CR4: 00000000003526f0 Call Trace: __sk_destruct+0x86/0x660 net/core/sock.c:2339 rcu_do_batch kernel/rcu/tree.c:2605 [inline] rcu_core+0xca8/0x1770 kernel/rcu/tree.c:2861 handle_softirqs+0x286/0x870 kernel/softirq.c:579 __do_softirq kernel/softirq.c:613 [inline] invoke_softirq kernel/softirq.c:453 [inline] __irq_exit_rcu+0xca/0x1f0 kernel/softirq.c:680 irq_exit_rcu+0x9/0x30 kernel/softirq.c:696 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1052 [inline] sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1052 The Linux kernel CVE team has assigned CVE-2025-39913 to this issue. Affected and fixed versions =========================== Issue introduced in 4.17 with commit 4f738adba30a7cfc006f605707e7aee847ffefa0 and fixed in 6.1.153 with commit 9c2a6456bdf9794474460d885c359b6c4522d6e3 Issue introduced in 4.17 with commit 4f738adba30a7cfc006f605707e7aee847ffefa0 and fixed in 6.6.107 with commit 66bcb04a441fbf15d66834b7e3eefb313dd750c8 Issue introduced in 4.17 with commit 4f738adba30a7cfc006f605707e7aee847ffefa0 and fixed in 6.12.48 with commit 539920180c55f5e13a2488a2339f94e6b8cb69e0 Issue introduced in 4.17 with commit 4f738adba30a7cfc006f605707e7aee847ffefa0 and fixed in 6.16.8 with commit de89e58368f8f07df005ecc1c86ad94898a999f2 Issue introduced in 4.17 with commit 4f738adba30a7cfc006f605707e7aee847ffefa0 and fixed in 6.17 with commit a3967baad4d533dc254c31e0d221e51c8d223d58 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-39913 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: net/ipv4/tcp_bpf.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/9c2a6456bdf9794474460d885c359b6c4522d6e3 https://git.kernel.org/stable/c/66bcb04a441fbf15d66834b7e3eefb313dd750c8 https://git.kernel.org/stable/c/539920180c55f5e13a2488a2339f94e6b8cb69e0 https://git.kernel.org/stable/c/de89e58368f8f07df005ecc1c86ad94898a999f2 https://git.kernel.org/stable/c/a3967baad4d533dc254c31e0d221e51c8d223d58