Article View: linux.kernel.netdev
Article #12773[PATCH ipsec v2 6/7] xfrm: segment untrusted GSO packets before sequence allocation
From: Jérémy Jean
Date: Sun, 08 Nov 2026 14:26
Date: Sun, 08 Nov 2026 14:26
52 lines
11702 bytes
11702 bytes
Packets received through TUN or virtio-net can have gso_segs == 0,
with SKB_GSO_DODGY set until the segmentation metadata is checked.
When ESP defers segmentation, gso_segs is still zero, so the SA
sequence counter is not advanced. The segments receive sequence
numbers starting at oseq + 1, which subsequent packets can reuse,
causing AES-GCM nonce reuse.
This affects IPv4 and IPv6, with or without ESN, when the ESP offload
type is registered. Hardware encryption is not required.
Segment SKB_GSO_DODGY packets in xfrm_output() before allocating
sequence numbers, so each segment gets its own number. Set the ESP
encapsulation flag in xfrm_output_one(), after early segmentation, so
UFO fragment offsets and flags are filled in correctly.
Fixes: d7dbefc45cf5 ("xfrm: Add xfrm_replay_overflow functions for offloading")
Cc: stable@vger.kernel.org
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
net/xfrm/xfrm_output.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index 99d1b33db52a6..a1fb60971c6bc 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -505,6 +505,9 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
if (err <= 0 || x->xso.type == XFRM_DEV_OFFLOAD_PACKET)
goto resume;
+ if (xfrm_offload(skb))
+ skb->encapsulation = 1;
+
do {
err = xfrm_skb_check_space(skb);
if (err) {
@@ -814,10 +817,10 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
xfrm_state_hold(x);
xfrm_get_inner_ipproto(skb, x);
- skb->encapsulation = 1;
if (skb_is_gso(skb)) {
- if (skb->inner_protocol && x->props.mode == XFRM_MODE_TUNNEL)
+ if ((skb_shinfo(skb)->gso_type & SKB_GSO_DODGY) ||
+ (skb->inner_protocol && x->props.mode == XFRM_MODE_TUNNEL))
return xfrm_output_gso(net, sk, skb);
skb_shinfo(skb)->gso_type |= SKB_GSO_ESP;
--
2.47.3
Technical Details
Message-ID:
<20261108142652.1330952-7-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-358771-linux-kernel-netdev=dewy.ruReferences:
<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-358771-linux-kernel-netdev=dewy.ru From: Jeremy.Jean@oss.cyber.gouv.fr (Jérémy Jean) Newsgroups: linux.kernel.netdev Subject: [PATCH ipsec v2 6/7] xfrm: segment untrusted GSO packets before sequence allocation Date: Sun, 8 Nov 2026 14:26:51 +0000 Organization: Usenet Network Message-ID: <20261108142652.1330952-7-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="141641"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:J2rgLUmmHmbeIxf/W3jJSf6gccQ= sha256:K/BWNjYPKAAWaj0ScwiqTinVS9l2Hy6JjMXuk8XrKZg= sha1:V2Nal8copoiXXyC2Ua7GBt2WrlU= sha256:Y2FeE99l4XDisDbz70Uqgiml3sQLhN2AcKXr0yY6Pp0= 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 2C2851135A5; Sun, 8 Nov 2026 17:32:32 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 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, URIBL_BLOCKED=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 fD-46vSgPdy9; Sun, 8 Nov 2026 17:32:29 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-358771-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id B920E113587; Sun, 8 Nov 2026 17:32:20 +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 3892A2DF09; Sun, 8 Nov 2026 14:27:51 +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=1794148044; b=AQVtc7KeipWhenAubYjOG//baeo5A7oMcCEHIlxRQPUuWbF/5vvAN3ojYY12pcvyADFC wYI7V+6OpwHHezvkqUsamTJ3RhQZniKEsJyl4PnX65HsJ5Qzb6W/mXPgerMV1t/aM9Qng 0T76kvtG3JXt6JRAXT7wvnQmcHZJ7djAilpS+aP997PWs34tdcL+Xk3pPctg3njz/If0b IpTjKrd6NiqwC+saeJMWBRSl54AjIQXq1df9YPu7nSX62cbwE2kNW55M86ogtQyZFaH74 WujR2LCEv7CncCTUljXHTRMtPkIoFQRVkP3Swip+ujmD3vlu3bXcXuJ1p8Vsq8GxRzg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794148044; 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=rkYS/CEtmuPr5G4354NxU68uWYFEiDlmwZzOtfMp6Z4=; b=AlJRunk/5S0RizDhgXUMYphEnqfvdo14wbvD/HlV/kvT9KYhWkhfMwd9T0JjoIpNQpwN rPWQWWI2M1KSGSORonaXAMUwWi4MljpzSJbmmUNagirJLIv8dLsynRWixYNhzG+jEgzr7 yvVsTzdjnYrG5sxyaqeR7sTLPlC9Dp2mVSMQJn4AUlbwOP876m9QddW/SF/BD+oaD6TR9 wVexVxuG2RCRyKKN0j0zBcYXhGc8I/PMAsiO+Fdrjn16zN0O5e9/5emSdxIWK5oSCC9qx yOWyCI2lTs5Owyp79NGlLHwYqAIgQ7fwQxrQEuql5RHGOFLyarXwv2kW6I4+eFjpCxQ== 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=MwWpvquV; 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 B7C80606D806; Sun, 8 Nov 2026 14:27:24 +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=MwWpvquV 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=1794148033; b=sgM2IrLxyxDgQcbN3TMkpMGtFqTD6ifbeT2tWGUDFNWBu8ZqzIVhL3aJBvls64SVqcDb /To2dhoc7qmLHVAJEjJ2cab6XLRisC7N7KGLEcfPPYuLTMy2ATx0HfyWJOhYLH89Ft6/0 G9CaU+FjKkZl0ZSRs45z+/fTLh54iothP6wOuNmAdlwzWZvydexeT6oGiy9d1BQCtTeFw 5skpUEi/iyiCZZViMKXh+ovNAjrSTD19kqxTXXmRhJ04A1l2tr8/kWGZxorz+2GfW1dum tqrOsdyD3NO/wRIgkWonbIl0g2wgIDRl54C30fugR8vXrusZwUY1vqml914VFcicurg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794148033; 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=rkYS/CEtmuPr5G4354NxU68uWYFEiDlmwZzOtfMp6Z4=; b=ZBtfHFPDzLT2exbE7L7zmPQMx+kqEP0y3LgOlWyYVe1GuW+BYoAhDzDQaJ3+KUKX0DM4 Rt53G0mToSNQ3iZoCvRSTqX1QZl3k/Li0JpmHaJx87Y02N0AZ8qIaGDvdtUpp/Qspgu0q iLyldLyQ+rWSBWjUEv8NR0FwRBs2pbD0ghmsXKEJsuycHgVzCu+aA0scbjt+JAyeEArN3 QeJ/HzCdVM/SvsO/JYlQycMksy4Phuj7WDAUAJhiGxp7cvavYTvBW+YONfRX5wtMHTZjh l1mQLA8y7fBUUC/3b0FE8VqmqnrYLaMkAffxsPGkYj/GRAmx671MkfG7IsNaEJo7EEA== 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=MwWpvquV; 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 69A66606D832; Sun, 8 Nov 2026 14:27:02 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 69A66606D832 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=rkYS/CEtmuPr5G4354NxU68uWYFEiDlmwZzOtfMp6Z4=; b=MwWpvquV6KKbx8ACObdGBsJZ/I +vu/W6RO7//F3daN+lYbq3q6uJE6DsjBsqYq/+6F75u3Avuogrvx1SNDdU7obCvV/Yqidr0V5Hexe 0yUeYIEsWuqllIBFxSLaB0MmKZ/DI9K14m8/nb6WVZnkaCReXqP4ysE/zJR0zDVL1QN+llP2Yk483 0eAnTVxkNkmRfwbKuG6W0UjIwAtJIqa1Ix8NBWRu/k3lnaGlsvQNL6Fz4sXgcKi8LV7OFTtWAi6qy 7ElmxWgCtrIjMrBF2xtK/V98fmvfLVpvZU1If9ywXveJGTyuWs4ygOdtyxU5AMXUPr99Yg3EqmFIF CyHHtTnw==; 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 1xQ3rI-00000008IcJ-37Ao; Sun, 08 Nov 2026 15:27:00 +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