🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12768

[PATCH ipsec v2 4/7] xfrm: prevent AES-GCM nonce reuse after early GSO

#12768
From: Jérémy Jean
Date: Sun, 08 Nov 2026 14:26
49 lines
11616 bytes
With software ESP offload, xfrm_output() attaches a secpath before
calling xfrm_output_gso() for an encapsulated GSO packet, but
skb_gso_segment() leaves the splitted skbs sharing the same secpath,
including xo->seq.

For the i-th splitted segment, xfrm_output_gso() reaches
xfrm_replay_overflow() through xfrm_output_one(), which allocates
sequence number N+i to that segment, and then incorrectly overwrites
the shared xo->seq with N+i. If encryption is delayed until all t
segments have been processed, xo->seq ends up with value N+t-1 for all
segments. When validate_xmit_xfrm() calls esp*_xmit() for each
segment, the IV is constructed from the same value N+t-1, causing
nonce reuse in AES-GCM. Yet, each ESP header correctly keeps using
value N+i from its private XFRM_SKB_CB.

Call secpath_set() for each offloaded segment before xfrm_output2(),
so sequence allocation writes to private metadata that cannot be
overwritten by later segments.

Fixes: a204aef9fd77 ("xfrm: call xfrm_output_gso when inner_protocol is set in xfrm_output")
Cc: stable@vger.kernel.org
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
 net/xfrm/xfrm_output.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index f1f612cd7b438..99d1b33db52a6 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -672,6 +672,15 @@ static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb
 	skb_list_walk_safe(segs, segs, nskb) {
 		int err;
 
+		/* Each segment reserves its own sequence number and stores
+		 * it in the secpath.
+		 */
+		if (xfrm_offload(segs) && !secpath_set(segs)) {
+			XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
+			kfree_skb_list(segs);
+			return -ENOMEM;
+		}
+
 		skb_mark_not_on_list(segs);
 		err = xfrm_output2(net, sk, segs);
 
-- 
2.47.3
Technical Details
Message-ID: <20261108142652.1330952-5-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-358768-linux-kernel-netdev=dewy.ru
References: <20261108142652.1330952-1-Jeremy.Jean@oss.cyber.gouv.fr>

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-358768-linux-kernel-netdev=dewy.ru
From: Jeremy.Jean@oss.cyber.gouv.fr (Jérémy Jean)
Newsgroups: linux.kernel.netdev
Subject: [PATCH ipsec v2 4/7] xfrm: prevent AES-GCM nonce reuse after early GSO
Date: Sun,  8 Nov 2026 14:26:49 +0000
Organization: Usenet Network
Message-ID: <20261108142652.1330952-5-Jeremy.Jean@oss.cyber.gouv.fr>
References: <20261108142652.1330952-1-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="140747"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:KVDeZhXngM/OckLKiMVTbjB9VKU= sha256:WRg2kyYfoFK1MpRCebX7SDwhsnCUNHEBNBUkZY/YfEk=
	sha1:b4IcCAEplBStBnf6DXNUsxM/mcU= sha256:LKW1O1JJY98AJdPZmOuY48s7inPZJN7+bDkJE0ipMIA=
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 2E7DC11359F; Sun,  8 Nov 2026 17:28:20 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.052
X-Spam-Status: No, score=-3.052 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,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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 OP71cNeqtF-u;
	Sun,  8 Nov 2026 17:28:15 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358768-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id E6AC6113587; Sun,  8 Nov 2026 17:28:06 +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 D422C60908; Sun,  8 Nov 2026 14:27:20 +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=1794148027;
	b=Udma6h7qQdLwlpkCEqaSuYH0Hl3wiNCjuhakKHE4AveuCo8SPyDVnPYCYSd2VAi5bv/T
	 tpbBVvMYbBcCiAPWBnIhQYcn/pm9EHECXuKBRltPCacBqpxLN22bHWXjW9Cxp8kfCi7Xe
	 DYTYVQaUc0MhcnM0QzhyVjLinvLnqD9pN1wm8ahr1RSrMdPugjEgqrniHCoGno4YXRZ/B
	 lILRqDisVmz8GHQfzU90T4Zxw3tFs7BGaYfnYYJb3TvRdcjA2CiadQefIS0ymZ9M0xcFZ
	 a6Gu7VXQpTG1LOT1yikqge1nqkifbfqRWn7YXeW98tb2FA3TdpQxdg7RN3fNmee80yg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794148027;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: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-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=gNojsi3GAmLLmeRMDSKN6Y0E5VJAy6rWp8R/Pes+NNs=;
	b=Q9tN6/NjFq0v92nFTRCQeIQTDB5wh9/YCY+3aUj0tQ35vXbTAjfgJdbTuApE1Vq4UDAb
	 XOM15OddAGGrd+sEoBscSOcW+ntBEYGWxyfVIfqo2zVV/e7b9SMx7YNJ2//HKvLdi+ltB
	 nWVyXpAXnboOtZWPrWAT5uy9i7EKBmA56I6KcEF50q+R68Ql0gWL4DS1L5nGKyaTQNYtZ
	 SPOUUzAH8XSUSUYA0qBne13MOr/bCB6jaEqL5ci3Gd78tD6ikQBGvHiI5svcQmMiKfNMu
	 c9Vcb0qK5PnWwMTFTF7CI0Y0ak3zYwn9KF2hJKLLAoqLmI2GgM+GcXZ23olyUWEofcw==
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=p8d33lI6;
	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 5D71A606D81E;
	Sun,  8 Nov 2026 14:27:07 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.a=rsa-sha256 header.s=default header.b=p8d33lI6
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=1794148021;
	b=PD4qzLRp3UTEIMIvi3cgQzCE10xDTb9jdpNxGm2ak66PdfpEON8R5Dlyf79sWC5pEWwU
	 zZhHg9nBO2mcqG+9NKsumgZzXkbSsujRR+OBucZbyc4xSPwdLyNTEr5lVAlZ/qdJHMK7L
	 /SyHxSo3rU8qq+GsqcCqg6ZdVCIZm3ArtGQKJBIpwTaBLT9w3WW5tGbsj1qlk4BuQpobv
	 PWmzjzgCUEqNs8a9/6xPX42iZL4GJTkN0gf94mu/TMnBuS0So0prIK4UOJXqOQb9GTgEQ
	 0MPPifEZZ1KTqgP/ZmpQ7ELSq0qg49imkE41n8Of5fk0g8HOeyBPklDJp64TTEhxN9w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794148021;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References: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=gNojsi3GAmLLmeRMDSKN6Y0E5VJAy6rWp8R/Pes+NNs=;
	b=wn01GzYMT/UVhdPwLtWXekQ70H8BfcJTfJvhMyaUHCXSkwO4GwsvYIENlafzsTifejnA
	 8ddVA/490HFAdIJ7H/c4Whh1QwpjKIor45e15OrXZuEZL8zwiBIJhkn6IRdTJmDGLFuqZ
	 yQcxgqq6Zvxrtz0E0nsfb2Yed/M5vUk82oosRsq6J1cg22oZVjhHraOCBHFeMhDeRsGtd
	 Q+hni1ea/zGsh31JKoYd9diynALiA/GzU7dMEdhWreIc5GP80Qi6lt6HTEFsP+ZnYNLJh
	 k1mvhJXj2jwDax33qQlHn9rx65INEiHs5Mjml1T2SH0f/c9i86MvTrxZHJQ8sQZfwXg==
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=p8d33lI6;
	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 DEF02606A33E;
	Sun,  8 Nov 2026 14:27:00 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DEF02606A33E
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:References:In-Reply-To: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;
	bh=gNojsi3GAmLLmeRMDSKN6Y0E5VJAy6rWp8R/Pes+NNs=; b=p8d33lI6LolQ3Y6dbmV8jQgASx
	QGWK9iEBGZtPl4++V0utfKE2+MdjvWud4dkG9QsduicckpvN/B8DyP8fHUcUd6LssJOUj4l7K5AgE
	Tuop8/roCdMjbSUHAfynaCVILOKyKEFwvgg4OdhqBTM2QdG30mcCAk5MB5fyO+7thAmQDsQ4L8CY1
	sFaLFa5XyG9GbSFrl4rffJ7xYl/Rbcrwduk7S4SnXaoLJYW/vTasDwH88cXgnE1yx6kx2xX5Mi+eC
	PVMB6ADVOdPRGEXavmchzwB4yKpqJKP5UB8bvphOY+0xTxpXEnxaKUpGOIm9NZUA+XLA+y2QpEHtk
	EIVKIjKA==;
X-Received: from [151.115.150.205] (port=49652 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 1xQ3rH-00000008IcJ-1n7q;
	Sun, 08 Nov 2026 15:26:59 +0100
X-Cc: "David S. Miller" <davem@davemloft.net>,
	Boris Pismenny <borisp@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leonro@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>,
	Mark Bloch <mbloch@nvidia.com>,
	netdev@vger.kernel.org,
	linux-rdma@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-In-Reply-To: <20261108142652.1330952-1-Jeremy.Jean@oss.cyber.gouv.fr>
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