🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #9530

[PATCH 14/14] xfrm4: use a full socket for local errors

#9530
From: Steffen Klassert
Date: Mon, 02 Nov 2026 10:04
56 lines
11505 bytes
From: Fourie Zhang <fouriezhang@tencent.com>

xfrm4_local_error() passes skb->sk to inet_sk() and ip_local_error()
without ensuring it points to a full socket. TCP SYN-ACK skbs can be owned
by TCP_NEW_SYN_RECV request sockets.

xfrm4_tunnel_check_size() already checks sk_fullsock() since commit
1620c88887b1 ("xfrm: Fix the usage of skb->sk"), so iptfs_is_too_big() is
the only remaining IPv4 caller passing a request socket here: the sk it
tests is the listener, while skb->sk is the request socket.

When IP-TFS rejects such an skb because it exceeds its payload MTU, the
local error path treats the request socket as a struct inet_sock. KASAN
reports a slab-out-of-bounds read in ip_local_error() beyond the
request_sock_TCP allocation.

Resolve the skb owner with skb_to_full_sk() before accessing inet_sock
state or reporting the error. This maps a request socket to its listener
and rejects sockets that cannot be used as full sockets, matching what
commit 6973a21ee73c ("ipv6: xfrm: use full sockets in local error paths")
did for xfrm6_local_error().

Fixes: 0e4fbf013fa5 ("xfrm: iptfs: add user packet (tunnel ingress) handling")
Cc: stable@vger.kernel.org
Reported-by: TencentOS Corvus AI <corvus@tencent.com>
Link: https://lore.kernel.org/netdev/20260908224856.1591189-1-kuba@kernel.org/
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Assisted-by: tencentos-corvus-ai:hy4-preview
Signed-off-by: Fourie Zhang <fouriezhang@tencent.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv4/xfrm4_output.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c
index 0ae67d537499..fffa3c4f456e 100644
--- a/net/ipv4/xfrm4_output.c
+++ b/net/ipv4/xfrm4_output.c
@@ -38,9 +38,12 @@ int xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 
 void xfrm4_local_error(struct sk_buff *skb, u32 mtu)
 {
+	struct sock *sk = skb_to_full_sk(skb);
 	struct iphdr *hdr;
 
+	if (!sk)
+		return;
+
 	hdr = skb->encapsulation ? inner_ip_hdr(skb) : ip_hdr(skb);
-	ip_local_error(skb->sk, EMSGSIZE, hdr->daddr,
-		       inet_sk(skb->sk)->inet_dport, mtu);
+	ip_local_error(sk, EMSGSIZE, hdr->daddr, inet_sk(sk)->inet_dport, mtu);
 }
-- 
2.53.0
Technical Details
Message-ID: <20261102100451.2505200-15-steffen.klassert@secunet.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354512-linux-kernel-netdev=dewy.ru
References: <20261102100451.2505200-1-steffen.klassert@secunet.com>

Show 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-354512-linux-kernel-netdev=dewy.ru
From: steffen.klassert@secunet.com (Steffen Klassert)
Newsgroups: linux.kernel.netdev
Subject: [PATCH 14/14] xfrm4: use a full socket for local errors
Date: Mon, 2 Nov 2026 10:04:12 +0000
Organization: Usenet Network
Message-ID: <20261102100451.2505200-15-steffen.klassert@secunet.com>
References: <20261102100451.2505200-1-steffen.klassert@secunet.com>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2877522"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rP9iRuWooTXR9DZxju0iMUHQ0MU= sha256:/hSzOCL7HYIkMcorky2RPOy7UzCuTqKHxTvPiHtMrVg=
	sha1:Zgj8u4SeQ/H6dMJhUTBEHniUGZA= sha256:TzrKtHzwTuMcFktSZKuuduLk+krOmAnvE1DhVfAJW/c=
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 3B682112455; Mon,  2 Nov 2026 11:06:57 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=secunet.com
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 bQz7YoPu7t9V;
	Mon,  2 Nov 2026 11:06:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-354512-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=secunet.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 75058112423; Mon,  2 Nov 2026 11:06:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 977002D45C; Mon,  2 Nov 2026 08:04:54 +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=1793606691;
	b=WE0QD03ed/wPlmd05l3OZQfK1++HgqNzVaqS352sqKqRIqinT6KVT9+L2S5DEggAZshp
	 P8fn+B2CI5iLCpiBqzpjtd/aO+sZ+pCEHQQxfaEpkaXVRbBIavoHzbXYwolErN3Viobys
	 v+YLejrfCiTmEiVCC5dqg43jP+fi55lInwV81vVD1bv/kH/fzwuVon+3KlAuxATc5PITg
	 Rw+jh4OOxjolfmKXwZ14vkPDwByM8VV4Wn+faJpaSq2v2u8ewGaTBO6a2Cx0AQkYBxyz5
	 GOYkeekN1qVZpT6BfDeB2osfccgnaT2FJZTlWJdFAOQk7EVUQK6nCy/W1mnYhkcGz3w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793606691;
	h=X-Original-To:Received:DMARC-Filter:Received:X-Virus-Scanned:
	 Received:Received:DKIM-Filter:DKIM-Signature:Received:Received:From:
	 To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy;
	bh=thBVD6OEHrAcgPMGcHGCuTpwhbDxLXvR0Dj8bMZ3KCM=;
	b=aUUT6A/XkP0uSfrz9dlOdPCtA7EjG4KWQZG+PgvNieCjRXgs5oz4YQ1RiKNZbCIh+gxc
	 jD5r4IsPKK41U6UDQ6+HGd141XJbyK2VokHUMIAkhsXkd591rrv99JwqLRPDyIT9jBOhR
	 ZAMkzPfdZ9TUQ+fxt06Puo/JvDGlJCH4/3dcD8EUEtC0YDzzAyMEFQ7st56xe4Vkk+eAn
	 9j9VC9+Uwh6Z3VJz0QqUa7zBrd/fbnoNwLRI6kEYZZtE/4vryhq2cS8d83v2ekZswhIb3
	 W+EcUSGcQOSKXEvrfwQdQ0XToxbQXut7RBFNXJgY+XMfQKjZ1dj8Uk2i2+g3wAEMozg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=uoMAiMyr;
	dmarc=pass header.from=secunet.com;
	spf=pass smtp.mailfrom=secunet.com;
	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 E6E0B60A260A;
	Mon,  2 Nov 2026 08:04:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=uoMAiMyr
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.96.220.36
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793606690;
	b=DmsXe+0HBql5BYVAFWjdXuiM7bSdMb69jhBVuc0NxUDc3SQpXyyPi1T1aKZIydoXjhJB
	 /gzexHUyRXVZpl8d93kGWcwo1M+sYgeTu4Swv/x+3FIHsvojDGqji8bvrYrSJ6UEgG4qe
	 ngEM6ilnrciBXm9pEaTjP1x0jjxwbtQyVCEEdz43COybRzpb2OrDFo23/Axc+QaSrNLW6
	 zgobrL3bE9OiD88yC64DkeJH9MEjqSqCAQJcDhxFVvIxL2pVNfYg479kpuBlkQubCwUIk
	 vOpxmEhinxjnt6YQuVoVvO7YALg0cb+iU/1fhHj+K1ihSbJN6ACZ+xqjz1Uk8b/UW4w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793606690;
	h=DMARC-Filter:Received:X-Virus-Scanned:Received:Received:DKIM-Filter:
	 DKIM-Signature:Received:Received:From:To:CC:Subject:Date:Message-ID:
	 X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy;
	bh=thBVD6OEHrAcgPMGcHGCuTpwhbDxLXvR0Dj8bMZ3KCM=;
	b=T2FR8syaC1iO2PG2TFVMmE8lk/b683kzgomaTLknMUsatoOBm8VyUajjxVblRsFCXHkH
	 FOs6RyEEBGqCqjaU1dsWa4nuJTUsvP/63H6Ers5WSoZB/KVxwFVPgMqujF+cjP0AEbfDY
	 J+MeZVos3rIULhc3Uf1wD3k1WVAOuiDqTKvRCzKsosp48i0ZTXmsSDohZNgk0zJ6gssAF
	 YimTTLjpMLDwc/9AH0NNYZQe/Mw4+9jsnGAohUzuWaMSoJ4D3D1iM/u5pMwitLipDFMUA
	 2tBR1M5Mox50AjbXWDSqE9n1fQUUxj3yXAhJAPdi5Efsy40H1Q7E2OgS94+xnGC5GfQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=secunet.com;
	spf=pass smtp.mailfrom=secunet.com;
	dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=uoMAiMyr;
	arc=none smtp.remote-ip=62.96.220.36
X-Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33D59606A335
	for <netdev@vger.kernel.org>; Mon,  2 Nov 2026 08:04:48 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 33D59606A335
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com
X-Received: from localhost (localhost [127.0.0.1])
	by mx1.secunet.com (Postfix) with ESMTP id 691F8207C1;
	Mon,  2 Nov 2026 09:04:42 +0100 (CET)
X-Virus-Scanned: by secunet
X-Received: from mx1.secunet.com ([127.0.0.1])
 by localhost (mx1.secunet.com [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 5wmmy2YTnOvJ; Mon,  2 Nov 2026 09:04:40 +0100 (CET)
X-Received: from EXCH-01.secunet.de (rl1.secunet.de [10.32.0.231])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by mx1.secunet.com (Postfix) with ESMTPS id 80D01207A4;
	Mon,  2 Nov 2026 09:04:40 +0100 (CET)
X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 80D01207A4
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com;
	s=202301; t=1793606680;
	bh=thBVD6OEHrAcgPMGcHGCuTpwhbDxLXvR0Dj8bMZ3KCM=;
	h=From:To:CC:Subject:Date:In-Reply-To:References:From;
	b=uoMAiMyrMnoueFcHt7jKQ94TnOO6qc9lv+WGoiRuebx0CRhZ77dJFk4IvbIRO6nHF
	 9klrfkx+ACkqiPBXBDHSEtAZaog6xIw46CaCmPWNwstauu883eZ23TPTml+RlWPemm
	 lInjp+lsOYzSsPMXlH0Oqp3qHgrK5NqETgsRceBbpR2x3QjMyjPp3pynK3/mgNhOEr
	 IUpWNMOpJO28AAsmqwS/I4WVyGKeGTRtK388AziWn31hJ6154WWcBAl8ijmLJZrCHt
	 x1YC/O0zs/4GSY2Ndvq0fbnHNkQvwoqdDm96okVXjt4zpLnX0ODk+ptr2om/MSrs0S
	 3pGJFfpzqnK3Q==
X-Received: from gauss4 (10.182.7.102) by EXCH-01.secunet.de (10.32.0.171) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Mon, 2 Nov
 2026 09:04:39 +0100
X-Received: (nullmailer pid 2505930 invoked by uid 1000);
	Mon, 02 Nov 2026 10:04:58 -0000
X-CC: Herbert Xu <herbert@gondor.apana.org.au>, Steffen Klassert
	<steffen.klassert@secunet.com>, <netdev@vger.kernel.org>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261102100451.2505200-1-steffen.klassert@secunet.com>
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
X-ClientProxiedBy: EXCH-03.secunet.de (10.32.0.183) To EXCH-01.secunet.de
 (10.32.0.171)