🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6709

[PATCH net] inet: frags: prevent acceptance of partially authenticated reassembly

#6709
From: Jérémy Jean
Date: Fri, 23 Oct 2026 07:45
116 lines
13653 bytes
A reassembled skb retains the secpath from its first fragment, which
makes it possible for the final policy check to accept bytes that were
not covered by the transform recorded on the skb. This can affect IPsec
tunnel traffic, including AH and ESP, and allow a packet to be accepted
even though only part of its payload was authenticated.

Reject a fragment when its secpath differs from the fragments already
in the queue, and keep overlap statistics limited to actual overlaps.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
 include/net/inet_frag.h  |  1 +
 include/net/xfrm.h       | 17 +++++++++++++++++
 net/ipv4/inet_fragment.c |  5 +++++
 net/ipv4/ip_fragment.c   |  3 ++-
 net/ipv6/reassembly.c    |  3 ++-
 5 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index 365925c9d2628..b02d2472b003e 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -171,6 +171,7 @@ extern const u8 ip_frag_ecn_table[16];
 #define IPFRAG_OK	0
 #define IPFRAG_DUP	1
 #define IPFRAG_OVERLAP	2
+#define IPFRAG_MIXED_SECPATH	3
 int inet_frag_queue_insert(struct inet_frag_queue *q, struct sk_buff *skb,
 			   int offset, int end);
 void *inet_frag_reasm_prepare(struct inet_frag_queue *q, struct sk_buff *skb,
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index a6d69aaa6cd2d..493faac0faa45 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1201,6 +1201,23 @@ secpath_reset(struct sk_buff *skb)
 #endif
 }
 
+static inline bool
+secpath_equal(const struct sk_buff *skb1, const struct sk_buff *skb2)
+{
+	const struct sec_path *sp1 = skb_sec_path(skb1);
+	const struct sec_path *sp2 = skb_sec_path(skb2);
+	int i;
+
+	if (!sp1 || !sp2)
+		return sp1 == sp2;
+	if (sp1->len != sp2->len || sp1->verified_cnt != sp2->verified_cnt)
+		return false;
+	for (i = 0; i < sp1->len; i++)
+		if (sp1->xvec[i] != sp2->xvec[i])
+			return false;
+	return true;
+}
+
 static inline int
 xfrm_addr_any(const xfrm_address_t *addr, unsigned short family)
 {
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index b286ee429da8f..c18da91c1f031 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -23,6 +23,7 @@
 #include <net/inet_ecn.h>
 #include <net/ip.h>
 #include <net/ipv6.h>
+#include <net/xfrm.h>
 
 /* Use skb->cb to track consecutive/adjacent fragments coming at
  * the end of the queue. Nodes in the rb-tree queue will
@@ -441,6 +442,10 @@ int inet_frag_queue_insert(struct inet_frag_queue *q, struct sk_buff *skb,
 {
 	struct sk_buff *last = q->fragments_tail;
 
+	/* The reassembled skb keeps the first fragment's secpath. */
+	if (last && !secpath_equal(last, skb))
+		return IPFRAG_MIXED_SECPATH;
+
 	/* An IP fragment is never a GSO packet, but an untrusted source
 	 * (virtio_net_hdr) may have attached GSO metadata to it. Do not let
 	 * that reach the reassembled skb, whose head keeps the first
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index c790d2f494870..36105dd192823 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -378,8 +378,9 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb, int *refs)
 		err = -EINVAL;
 		goto err;
 	}
+	if (err == IPFRAG_OVERLAP)
+		__IP_INC_STATS(net, IPSTATS_MIB_REASM_OVERLAPS);
 	err = -EINVAL;
-	__IP_INC_STATS(net, IPSTATS_MIB_REASM_OVERLAPS);
 discard_qp:
 	inet_frag_kill(&qp->q, refs);
 	__IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS);
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 05c51f669754a..53a685f5c6b7f 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -240,8 +240,9 @@ static int ip6_frag_queue(struct net *net,
 		err = -EINVAL;
 		goto err;
 	}
+	if (err == IPFRAG_OVERLAP)
+		__IP6_INC_STATS(net, idev, IPSTATS_MIB_REASM_OVERLAPS);
 	err = -EINVAL;
-	__IP6_INC_STATS(net, idev, IPSTATS_MIB_REASM_OVERLAPS);
 discard_fq:
 	inet_frag_kill(&fq->q, refs);
 	__IP6_INC_STATS(net, idev, IPSTATS_MIB_REASMFAILS);
-- 
2.47.3
Technical Details
Message-ID: <20261023074515.2347924-2-Jeremy.Jean@oss.cyber.gouv.fr>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350949-linux-kernel-netdev=dewy.ru

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-350949-linux-kernel-netdev=dewy.ru
From: Jeremy.Jean@oss.cyber.gouv.fr (Jérémy Jean)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] inet: frags: prevent acceptance of partially authenticated reassembly
Date: Fri, 23 Oct 2026 07:45:16 +0000
Organization: Usenet Network
Message-ID: <20261023074515.2347924-2-Jeremy.Jean@oss.cyber.gouv.fr>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="441472"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:gnDfltldrm02kUTfhaXiRtw/6ts= sha256:stnGP1Xqqe7WUOkcEzbM0VSieUl4HX8lW+vAXFs08+A=
	sha1:WbDiUG3FZWcLFuIsrPtbaostKtU= sha256:JGpV6HWU7HBAOo/DzguoX83hKB0StJSMpacK/qg8SgE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
	X-Source
	X-Source-Args
	X-Source-Dir
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 88BB4111426; Fri, 23 Oct 2026 10:48:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.389
X-Spam-Status: No, score=-3.389 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, 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]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=oss.cyber.gouv.fr
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 qn8jWF4gf_IH;
	Fri, 23 Oct 2026 10:48:52 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350949-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=oss.cyber.gouv.fr
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 5663F11141B; Fri, 23 Oct 2026 10:48:44 +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 8BECB3AAB2; Fri, 23 Oct 2026 07:45:38 +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=1792741538;
	b=ATdZfs2FhEWuJaPs3rGOj2DLxpAYqYO/nC+xk/rkZeuq7y6r2/I+BhozRSbU/2GEN3q5
	 4epWGjNHlFtuRdT2cPKymhnYlJxLTm8bo6v6TYa0mT4SAHy//Mk5JgfiBROubbhp4H09F
	 olptFOpEDlDnBjfWCMKSd2MSB7GCXQVaYQ/xx8CJrqeBSNdfsT7xF0ri+hOb2ewFWP3ov
	 JKOQuKPKBK/H+2OIeY6o1dfAg3eKN4lxexw19ynUMX8EdB0AXOxM/zHNG7Owvp9IU8AzO
	 PGFe4cb+gR+bC1BNRyi/sGXPzX8NudIf1qywYrD9dwF1+lBcuMDBhCQMW/xhOBcPZKw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792741538;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received: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-Type:Content-Transfer-Encoding:X-AntiAbuse:
	 X-AntiAbuse:X-AntiAbuse:X-AntiAbuse:X-AntiAbuse:
	 X-Get-Message-Sender-Via:X-Authenticated-Sender:X-Source:
	 X-Source-Args:X-Source-Dir;
	bh=E7+eeDnrpYAQAno1bPo/PnYZK3Z5dkIdEaeua04xbzY=;
	b=q45S97/7DpbxWjaSywtuSQNy2rNHxvNMgYPptKyuzdCBRSlzc3kF45WDcinfiJaIIIf+
	 1NYvFLNz1+92slDg/cfVu3+1Sy+vnGM6k62hk41rUc4sCUjmrYweDBT1KaOjPoj39uuMu
	 nYPiIQIglm8S1y40qOcu76tqqI7s5CpZYAgRkceBz/UCE5IzWp+8tH0NXI6u2Y51HTdd+
	 VybkwmiommOsC+cIDoLL8YO0vM/P2i3DY7J99r/8Ud1WnWSkQbiZXltq5oZDQNSn12Oxx
	 F2ACln8/NZ1H7lg+PB+/sQNg7ns4hGBmQ2K4+og9leHE8IWtdFfpWMU5y5PJgx09mcw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.a=rsa-sha256 header.s=default header.b=Mkwjy1cZ;
	dmarc=pass header.from=oss.cyber.gouv.fr;
	spf=pass smtp.mailfrom=oss.cyber.gouv.fr;
	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 636C4606A32C;
	Fri, 23 Oct 2026 07:45:38 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.a=rsa-sha256 header.s=default header.b=Mkwjy1cZ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=51.159.188.251
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792741537;
	b=Atszi5wGUWlu21U8oimDW96p3BvTCy+odAqJBaO1Wgs7vcDm1YM3GlX6Cf5L8pidjBBY
	 3ogGQLkz3je5Dnfic5sUOGDg/itY7xrKpuO+05M26Rs9uCt5yQYzo4vCN1sxiq3AoxfO5
	 po/GOsW8tMx2ecNSeIDJ3czTIvBPLPe7jQ8OkKGyW0OWgz2bUArJWKKqLGB7mwNKviPuA
	 hzuELw5oef2iPKZEo3x4rZqFPqLVBqiq1kV+DDJyOwbGWtdZGOMO4fZplk5/Ax1N6dGBu
	 wZhpOeuU4r28Z3J2hpPt3nx/YMGbEZkJDXj4mjZy7Hz4lTGq55Y4rNvVLwdxseRaEbQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792741537;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:X-AntiAbuse:X-AntiAbuse:X-AntiAbuse:
	 X-AntiAbuse:X-AntiAbuse:X-Get-Message-Sender-Via:
	 X-Authenticated-Sender:X-Source:X-Source-Args:X-Source-Dir;
	bh=E7+eeDnrpYAQAno1bPo/PnYZK3Z5dkIdEaeua04xbzY=;
	b=Cpn9fBGcaeBtnjqbOxNdFl1wBm5x2zpL2VYjpF4cB0SLDp1mliRz7nqCp7Zvgt0JHnrn
	 Ss1O3Eaxm1YA0A6amZJOQeYavOPu+/75UiC3kxnN+LuK1hWZy108Im9PjrGpX9Nc5/5C5
	 jdNbb7OotRqSfewOlyd8kN2LCn1HKcvBFqEw0KBqdfNkyoA6nWuoyQbqyPZkjietXriQ5
	 qw4U3iVmjzFyoW89SE1G2gXfgkgsqebCM+HOJp1GwLDNt6+Q+Z0oHw3H5eqn0NDTyGdF/
	 /b8QBS9nx3q1uy4AYKwSqpcC/Blarta798myUzP74WK1V/BB8gOFj3lAmMjo2ZeRo6Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=oss.cyber.gouv.fr;
	spf=pass smtp.mailfrom=oss.cyber.gouv.fr;
	dkim=pass header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.a=rsa-sha256 header.s=default header.b=Mkwjy1cZ;
	arc=none smtp.remote-ip=51.159.188.251
X-Received: from oss.cyber.gouv.fr (oss.cyber.gouv.fr [51.159.188.251])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id D24C4606A31B;
	Fri, 23 Oct 2026 07:45:36 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D24C4606A31B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.cyber.gouv.fr
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.cyber.gouv.fr
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
	d=oss.cyber.gouv.fr; s=default; h=Content-Transfer-Encoding:Content-Type:
	MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Sender:Content-ID:
	Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
	:Resent-Message-ID:In-Reply-To:References;
	bh=E7+eeDnrpYAQAno1bPo/PnYZK3Z5dkIdEaeua04xbzY=; b=Mkwjy1cZgMYAVvHdtAIEhWhNS4
	LKB20OcUx0TN6vP/iqwqoM3vZzwUGK9wOl5kL13vMmjERfoliT5Oe/D0RVB0dQ/+Cl8TuY18TM4o0
	kwfqEP4vcpAfEc62Cn4GOqxxel5o0h+YofePQaMteWuCsRMD/ANc2ybJHiquIgbLM/G427wdCgeQx
	7lt/AqDsHGaHvcBPsvz2B3ylPx08Y6Iwn/N9aP6nsuiUXjLqojkr6MxR2b4TBqjy0PQODyqh6fynZ
	UtCkjpZZQvOMmBPZLROy1Bt1ASyDAv2Kcv2Atng/L6S3AL4T+F1aMCec8h18cUbfChKbbUR8nQntu
	NmQbBIwQ==;
X-Received: from [151.115.150.205] (port=34728 helo=gepetto..)
	by pf-012.whm.fr-par.scw.cloud with esmtpsa  (TLS1.3) tls TLS_AES_256_GCM_SHA384
	(Exim 4.100.1)
	(envelope-from <Jeremy.Jean@oss.cyber.gouv.fr>)
	id 1xK9xx-0000000HG6h-2CD4;
	Fri, 23 Oct 2026 09:45:28 +0200
X-Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.47.3
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-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - pf-012.whm.fr-par.scw.cloud
X-AntiAbuse: Original Domain - vger.kernel.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - oss.cyber.gouv.fr
X-Get-Message-Sender-Via: pf-012.whm.fr-par.scw.cloud: authenticated_id: jeremy.jean@oss.cyber.gouv.fr
X-Authenticated-Sender: pf-012.whm.fr-par.scw.cloud: jeremy.jean@oss.cyber.gouv.fr