🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13263

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

#13263
From: netdev-bot+sashiko
Date: Mon, 09 Nov 2026 15:08
106 lines
11769 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The code change is correct, but the commit message for "xfrm:
  prevent AES-GCM nonce reuse after early GSO" describes a narrower…

--

xfrm: prevent AES-GCM nonce reuse after early GSO

This commit calls secpath_set() on each segment in xfrm_output_gso() when
xfrm_offload() is set. As a result, segments produced by skb_gso_segment()
no longer share a single xo->seq. Each segment's IV is then built from its
own sequence number.

> xfrm: prevent AES-GCM nonce reuse after early GSO
>
> 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.

[ ... ]

> 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.

[Severity: Medium]
The code change looks correct. Is the commit message narrower than the bug
it fixes, though?

Is the problem limited to software ESP offload? In xfrm_output(), the early
GSO path runs for any state where xfrm_dev_offload_ok() is true. That
includes XFRM_DEV_OFFLOAD_CRYPTO states bound to a NIC:

net/xfrm/xfrm_output.c:xfrm_output() {
    ...
	if (xfrm_dev_offload_ok(skb, x)) {
		...
		if (skb_is_gso(skb)) {
			if (skb->inner_protocol && x->props.mode == XFRM_MODE_TUNNEL)
				return xfrm_output_gso(net, sk, skb);
    ...
}

In that case, xfrm_replay_overflow_offload() writes N+i into the shared xo
for each segment. If the segments are queued before validate_xmit_xfrm()
runs, esp_xmit() reads the shared value N+t-1. On the hw_offload branch it
then copies that value into the private xo:

net/ipv4/esp4_offload.c:esp_xmit() {
    ...
	seq = xo->seq.low;
    ...
	if (hw_offload && encap_type == UDP_ENCAP_ESPINUDP) {
		...
		esph->seq_no = htonl(seq);
	}
    ...
	if (hw_offload) {
		if (!skb_ext_add(skb, SKB_EXT_SEC_PATH))
			return -ENOMEM;
		...
		xo->seq.low = seq;
    ...
}

Drivers build the IV from this xo->seq. For example, mlx5e_ipsec_set_iv()
does:

	seqno = cpu_to_be64(xo->seq.low + ((u64)xo->seq.hi << 32));

and nfp copies xo->seq.low and xo->seq.hi into offload_info. Wouldn't
hardware crypto offload users hit the same nonce reuse?

Is the statement "each ESP header correctly keeps using value N+i"
accurate? For hardware offload with UDP_ENCAP_ESPINUDP, the
esph->seq_no = htonl(seq) assignment above overwrites the header with the
shared value. Every segment would then carry the same sequence number on
the wire, and the peer's anti-replay check would drop t-1 of the t
segments.

Is the problem specific to AES-GCM? In the software fallback, esp.seqno
feeds the seqiv-based IV for any counter-nonce AEAD the SA uses. That
includes rfc4106(gcm), rfc4309(ccm), rfc4543(gmac) and
rfc7539esp(chacha20,poly1305).

The new secpath_set() call in xfrm_output_gso() is guarded only by
xfrm_offload(segs), so the fix appears to cover all of these cases. Could
the subject and commit message be updated to mention hardware crypto
offload, the UDP encapsulation ESP header sequence number, and the non-GCM
AEAD modes?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261108142652.1330952-1-Jeremy.Jean%40oss.cyber.gouv.fr
Technical Details
Message-ID: <179423690370.994134.2277361511117933962@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-359384-linux-kernel-netdev=dewy.ru
References: <20261108142652.1330952-5-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-359384-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH ipsec v2 4/7] xfrm: prevent AES-GCM nonce reuse after early GSO
Date: Mon, 09 Nov 2026 15:08:23 +0000
Organization: Usenet Network
Message-ID: <179423690370.994134.2277361511117933962@kernel.org>
References: <20261108142652.1330952-5-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="385512"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jIAOlGrJ664ECX0GUH4hrXr34xw= sha256:71jPl70tRum2F8lYLfFAKY1GEzPfWIoneIo4DUwPvOk=
	sha1:yRuDgHsb1NAw8uHiyhKpejYTLAM= sha256:mIo9eG/vymgdtSosVVSryfp2T/VmNn/4XB5/RJL1hq8=
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 CEE93113848; Mon,  9 Nov 2026 18:16:46 +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 kL9cMUAU4oNW;
	Mon,  9 Nov 2026 18:16:42 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-359384-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 212F911370E; Mon,  9 Nov 2026 18:16:33 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 902FB2BD78; Mon,  9 Nov 2026 15:08:31 +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=1794236906;
	b=2kbLWt3mPaH8cBluRJtHZdoFU+wBB7QlOUvag+aO1bJiAax7z36vByRoWQzJgeeaCFgZ
	 DhT/9FLSRVAuh1XgC4aIYWkEQaHXMbcqTFYKyp9kJCs/dxLBkQFLE28ge6KjNnNWhMeXh
	 aXGAKq5R8rYl/r9NzhGFBnWoJIEdz5ER5PQZ3i5oTppQ0/CrSaO9YQI3pt+yD/5LeHxMk
	 aGkiH5OiAoA55W/CmRFi8bLN3+S9v0mJE7JLjA8SlIuo2GJQayDH+hSzXUcUL7FgiXgKL
	 X9FZjGeHaDsRQgL7+6vJDYQmOgVt4JBhtHpvh9vAFylNDHlSf28RPtad2afkAG0Mb7g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794236906;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=NcQSsbzqyco4Iw3u+HR1WbdmTXLgzsyGZKY4I0nDx4g=;
	b=QaQx3zxDEb4nF05B7EUBYaD1vH9wOKSyydiWdVGsy7LwkcWyGRiX6Z3rHIxgi+s1m4uD
	 y32CmoRtaYVxtgbUwzjekoCKQrLzS3kev17F6qpMNy+VoCdW2HWaBBv6gnD7xDc1s+h+U
	 O4qZQK1JIpnmuKjBUMLwhlkvyiTw6oPipejnnuqzXE36Dkrg4DabWwz100aKND7Eeb7MW
	 AcoToUtJIhfpQp2pw+nrGQ2wrLU8qlPIj+679md+YXXA9VLVM0jaNoaaMRrqGfJ1McUXg
	 6Yfwpv0+uZwePzVBwMIPlV9AP1h21w2ZzrsoPoR/0//hAkVl5/1swm1U1m7nvdSnXUw==
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=hjE1vUbw;
	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 33232606EE86;
	Mon,  9 Nov 2026 15:08:26 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hjE1vUbw
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=1794236905;
	b=RL5N8lOG2XP+dz5EsP3LMx1gasCAbLIg7nRmc8iVKXCUWact6MuzMGcggDBFJM7Io1VL
	 sl3NgAaulIkq7p9A5YvQVTjNe7hAYMQZmff4XvTHvZ3gQFIR/IoP9xqtCD967hXpLhWU4
	 kkvH3GbmaExFdv1Wo/ekAedIXYPbGSD6Dvkjb4eu20wqdKqphQd4dQVi1l5mrjTP4ue9b
	 0/CqukhHrpwa0di1w0kz5b4M2j6GnlyzScHaSFpuD8Ldt9g9o/eRewVhULoskKe3IWP5m
	 Q7uM/aKRIFMgfubBYyKTOGR2wX1RV1CyIaKvu8C/4vJVZIwGKMgc5ZboGQASjLj/0dA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794236905;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=NcQSsbzqyco4Iw3u+HR1WbdmTXLgzsyGZKY4I0nDx4g=;
	b=z2G7WOK0OaZmrR6ZyoNKTLt9psOGGRWHPqLPPn0EzjpUHPrit7o2RRwZhpOvM5F/19AX
	 RsGMQBVgAOLyw3nUZBaf0+hvHUJcMCzBSA83aL/l1al4VLDmp4MzlWQJ+06t7Dx4dq/Bw
	 vQg5vWU/ipoJRx9DOr9z6xHd1P1xiXLCi5+phqBwFcscLZOeadNKbl2fmKUP0qb3PzpRt
	 Wcfm+6cWvC0HWpVU6QwDMXYqHmmq3siAO9kyZI+8xVKmO8DAszh/BZJfQ62RT5mWqx4JB
	 iDFzGf5SBiKmSRq9I3Z/rDEwIYn73Yr7sUyJZXtfKOubTbyTDnn0STSFihyyqOaX12w==
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=hjE1vUbw;
	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 19808606A333;
	Mon,  9 Nov 2026 15:08:25 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 269DC1F008A1;
	Mon,  9 Nov 2026 15:08:24 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794236905;
	bh=NcQSsbzqyco4Iw3u+HR1WbdmTXLgzsyGZKY4I0nDx4g=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=hjE1vUbw/MMz5L3/c3e7VTt/XVkSOGHsTV3pWhlWM1HM5RWYYLmwYwfOCcIzbu3mp
	 UhO/J3C0hANhRN9HAY/oUSsuFqWA8Yd4qtX4XFftPVHk6Kx1R1JlvubmHfhg9grooV
	 tNx8QH6wA1auUk1qvoWjOtTLjscnhQSS1o5YUWE2BO/v+vMP53MB/uwo9SDheschzf
	 UpcV0NXyHznsKwhredcD2RPPg5JhZLh5rBxh8LvbeRET7a2XR9hILPVd2ecuMaoFEz
	 UhbZBo9z/KnEknIAztvDSDUN1p6sQ5zXvkGfX/XMMICJ17Pzx4acbvM7RrIuXmBP6i
	 ecvjMADGumsVQ==
X-Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au,
 sd@queasysnail.net, davem@davemloft.net, borisp@nvidia.com, saeedm@nvidia.com,
 leonro@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com,
 netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
 linux-kernel@vger.kernel.org, stable@vger.kernel.org, kuba@kernel.org
X-In-Reply-To: <20261108142652.1330952-5-Jeremy.Jean@oss.cyber.gouv.fr>
X-sashiko-severity: Medium
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