Article View: linux.kernel.netdev
Article #10971[PATCH net] net: require a full socket in sock_confirm_neigh()
From: Eric Dumazet
Date: Wed, 04 Nov 2026 13:29
Date: Wed, 04 Nov 2026 13:29
77 lines
10328 bytes
10328 bytes
From: Kyle Zeng <kylebot@openai.com>
An skb can retain dst_pending_confirm after its original output and
socket owner have changed. For example, a raw MSG_CONFIRM packet can
cross veth, have a TCP request socket assigned by TPROXY, and be bridged
into gretap. Neighbor output for the outer packet then calls
sock_confirm_neigh() with the request socket in skb->sk.
The helper unconditionally treats a non-NULL skb->sk as a full socket
when accessing sk_dst_pending_confirm. TCP request and TIME_WAIT sockets
do not contain that field. This produces an out-of-bounds four-byte read
and, if the word is nonzero, an out-of-bounds four-byte zero write. A
KASAN-enabled kernel reports:
BUG: KASAN: slab-out-of-bounds in ip_finish_output2+0xc9f/0xd60
Read of size 4 at addr ffff8880bdc3d880 by task tproxy_dst_conf/1771
Require sk_fullsock() before accessing the socket field, moving the
existing helper earlier in the header to make it available here. Keep
neigh_confirm() independent of the socket type so the skb's neighbor
confirmation still works, including for socketless packets. This also
covers the IPv6, VRF, and BPF neighbor-output callers.
Fixes: 4ff0620354f2 ("net: add dst_pending_confirm flag to skbuff")
Signed-off-by: Kyle Zeng <kylebot@openai.com>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
include/net/sock.h | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 0c1a6895d347..3144efad8c36 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2287,6 +2287,14 @@ struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie);
struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie);
+/* This helper checks if a socket is a full socket,
+ * ie _not_ a timewait or request socket.
+ */
+static inline bool sk_fullsock(const struct sock *sk)
+{
+ return (1 << sk->sk_state) & ~(TCPF_TIME_WAIT | TCPF_NEW_SYN_RECV);
+}
+
static inline void sk_dst_confirm(struct sock *sk)
{
if (!READ_ONCE(sk->sk_dst_pending_confirm))
@@ -2298,7 +2306,8 @@ static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n)
if (skb_get_dst_pending_confirm(skb)) {
struct sock *sk = skb->sk;
- if (sk && READ_ONCE(sk->sk_dst_pending_confirm))
+ if (sk && sk_fullsock(sk) &&
+ READ_ONCE(sk->sk_dst_pending_confirm))
WRITE_ONCE(sk->sk_dst_pending_confirm, 0);
neigh_confirm(n);
}
@@ -3031,14 +3040,6 @@ skb_sk_is_prefetched(struct sk_buff *skb)
#endif /* CONFIG_INET */
}
-/* This helper checks if a socket is a full socket,
- * ie _not_ a timewait or request socket.
- */
-static inline bool sk_fullsock(const struct sock *sk)
-{
- return (1 << sk->sk_state) & ~(TCPF_TIME_WAIT | TCPF_NEW_SYN_RECV);
-}
-
static inline bool
sk_is_refcounted(struct sock *sk)
{
--
2.53.0
Technical Details
Message-ID:
<20261104132900.1071940-1-edumazet@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356449-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356449-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH net] net: require a full socket in sock_confirm_neigh() Date: Wed, 4 Nov 2026 14:29:00 +0100 Organization: Usenet Network Message-ID: <20261104132900.1071940-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3397837"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:bOKw9VcIYe4NwjVkJW97HHzzWwE= sha256:Jo0xF17wkHNTOfrGUro7Wlt8ri1rftjVL0BosX1ict4= sha1:uv6n/NTBenZg4+fmoMzldmu4Ub8= sha256:+ief356Q3Q69iDg18U1SYkev4+8RyZehqewfUI6JRuE= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id D074B112BDB; Wed, 4 Nov 2026 16:34:18 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nTvWAJwJsGzg; Wed, 4 Nov 2026 16:34:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-356449-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 25737112BD1; Wed, 4 Nov 2026 16:34:06 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id A42AA25C76; Wed, 4 Nov 2026 13:29:06 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793798945; b=zXdgeizzdfvN098mZUqjvLL93b/+K9REqfgPV6JnmiKKvFhwX+NfD2fSU9CsdtIayjXI 9EVWnIJJwa0CE8SJoPa/IEX01DAYt3vJt+oUuX/vkpUE28q9mUJi7UylG97KAHQZyGsSN 0Tfebx6AiMiYull7wySFJ5eet1xGbTbfAsk6QnP9PSj8ZT2SsTO0QidWFsgVfSCGyXFM6 p0x/5eimtnRe8+DP+GYukpBMN+SQsxHvBIIZz0GlF7+JcJkegawVof/RO2eb+jTQQEE/K fYRI/YmPZeUSoLGG0j2RCCJxcfXgiifVXCax/QSFNqC9fTdaaNCWhLJCdRK0Dujg48Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793798945; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=e2yqxeW5iyA3GvtFtAiD65K4HSNLST1MrLwZ5EwDuxM=; b=g6cx9WeFSybBU7hRbc536GHWOqjn4G2EQz9bDky0wqGRM/CQuRN5MjzWq28/zBppQ0Jl U76m0VOlER3aJeNcCyvBHU27Oskuf7wZf4pVmg10OE7VS3akR5hMfnwhhLbtScCgujVo0 S8BsbDBLWjUuPMtz7qe1NsLItXUWN2IZtlT6WYXmePdKUiVoiG6EAYouD3igUkeEgVFSE RlN2Lwly4G7Kv4otbjH+V95Cp0XcGChooRpV4swC3H51nLx5Pz5HxOKhPY2wICFklXbSc qKSnCU8A8OK5IPtc8OFbb0pcUIjHjGnQrI07MElC76DNO0ClSSSVrRp4YfmuFX8l7/A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fkL7mEYC; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C738C606A330; Wed, 4 Nov 2026 13:29:05 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fkL7mEYC X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793798945; b=VQjDfj+syyXXwrAcQyceIU5FjgIPx0ErAXLCohvSV7hoeu8DfdjxGf5Ukp/bO+k0xwiJ LBHjE5by2Fv3JzdEW5zn3znwhNf9gjF0TwxoU0bXQRSceZ2F+WJfPbwGEwcGRWdARuVn6 fNiczeNjT1aB/vU4cY+b+dgUcuvptk1pqBAUkrPRxnOkpk6pdF1QGtdLPN60HPZbsbLcf jGaLy51DpcGaxCCJBYJNBcxboUlv/Kgg0kgNJj4ziiamD+Qtl0NEbGdAB40mqyTowNca+ pndubPqoUpFJhMRLga0H2ZCPJm4haJlm8W+brjAn/y2N4GHvsxtmuxQHId8FfBHU4RQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793798945; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding; bh=e2yqxeW5iyA3GvtFtAiD65K4HSNLST1MrLwZ5EwDuxM=; b=eMLfW9nFF9KUHU9La1UGdXVPNbkWZazyXdhIcVkfzjkE1UEs68/MJs7hlhsSSmuD1dLQ z6SrFBv3PNCEI0OxWSpYoGhrwCm3kR+twq5rahQcOcXKul5KtAjk1TPzNQQTDWwpgVY1Z 0eMUn+uVCboT3eiPSpWCGNyqYgs6vBCS4WpFsiyjD4PXchdkU/HsXeNuv6nMmKhfOggcu ywK0w/b0Gryx8oC6B1V15DtVh2Qq/i12B4nsU9uemloHyigT0re5VxTlKpSyDUZjds94Q KjMpT7aQc3+DhmJjgC7zlAairZqKg84WWf/Y2OmCD1JB1YQDosNcMDTWbrqyER+oWOQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fkL7mEYC; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2A83606A31B for <netdev@vger.kernel.org>; Wed, 4 Nov 2026 13:29:04 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D75D1F00A16; Wed, 4 Nov 2026 13:29:01 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793798944; bh=e2yqxeW5iyA3GvtFtAiD65K4HSNLST1MrLwZ5EwDuxM=; h=From:To:Cc:Subject:Date; b=fkL7mEYCJm3nzPQx0GTKvQ752gU2em3ImtrVVDYI4TqvBwNJhJwM2+AqZsNR8KMHY ZsbDFXeo+G0rhUAewFY+acux3sybR09Z+7yWkNdpLwY9pxptse1X8iEhOxq6aZVESj mO8+kVaD8iU8UjgwbrVPQMjeRKMdAe0/vu/2/UbkOCsUGa5vOV/EQP+MHfE8Tu9HlM l11imL9bHMOAlJjZ1cmHJSL2GPbxeZCx6U75nSsbLlpsLuYjv8F33DzS1wB+5i81cN 7kIpJ+2Bk43mx2p770YBVr4rXUFaO2NZgT9xx5cC2pe7JC5Pb7UMigcXcB3heiHq9X k6pWtCbhG2h3Q== X-Cc: Kuniyuki Iwashima <kuniyu@google.com>, Willem de Bruijn <willemb@google.com>, Simon Horman <horms@kernel.org>, netdev@vger.kernel.org, edumazet@kernel.org, Kyle Zeng <kylebot@openai.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list