🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5272

[PATCH net v2] xfrm: esp: reset outer TCP GSO metadata on espintcp input

#5272
From: Guoshuai Yang
Date: Tue, 20 Oct 2026 03:04
116 lines
15563 bytes
When ESP packets are received over TCP (RFC 8229 espintcp), strparser
slices individual length-prefixed ESP records from the outer TCP stream by
cloning the incoming TCP skb(s) in __strp_recv().

If the outer TCP skb was GRO-coalesced before reaching strparser, its
skb_shinfo carries the outer TCP stream's GSO metadata (gso_size, gso_segs,
and gso_type). When an ESP record spans two outer TCP segments, strparser
chains the spillover clone onto skb_shinfo(head)->frag_list.

Subsequently in esp_input() and esp6_input(), skb_cow_data() unshares the
head skb via pskb_expand_head() (preserving the outer TCP gso_size and
gso_type in the new private skb_shinfo) and calls skb_copy() on each cloned
frag_list member, which copies the outer TCP GSO fields via
skb_copy_header() onto a linear frag_list child skb allocated from slab
with head_frag == 0.

After ESP decryption and header removal, the resulting single inner packet
still has skb_is_gso(skb) == true with the stale outer TCP gso_size, while
skb_headlen(head_skb) is now smaller than that gso_size due to stripping
the outer framing and ESP header. When this packet passes through
gro_cells_receive() (which flushes frag_list packets via GRO_NORMAL
without resetting gso_size) and is forwarded, validate_xmit_skb() invokes
tcp_gso_segment() -> skb_segment(). Because head_skb is shorter than the
stale gso_size and SKB_GSO_DODGY is not set, skb_segment() attempts to map
the slab-backed frag_list member as a scatter-gather page fragment and hits
BUG_ON(!list_skb->head_frag):

  Internal error: Oops - undefined instruction: 0 [#1] SMP ARM
  PC is at skb_segment+0x574/0xd20
  LR is at skb_segment+0x884/0xd20
  Call trace:
   skb_segment from tcp_gso_segment
   tcp_gso_segment from inet_gso_segment
   inet_gso_segment from skb_mac_gso_segment
   skb_mac_gso_segment from __skb_gso_segment
   __skb_gso_segment from validate_xmit_skb
   validate_xmit_skb from __dev_queue_xmit
   __dev_queue_xmit from ip_finish_output2
   ip_finish_output2 from ip_output
   ip_output from ip_sublist_rcv_finish
   ip_sublist_rcv_finish from ip_sublist_rcv
   ip_list_rcv from __netif_receive_skb_list_core
   __netif_receive_skb_list_core from __netif_receive_skb_list
   __netif_receive_skb_list from gro_normal_list
   gro_normal_list from gro_cell_poll

Furthermore, if a decrypted inner packet with a frag_list later takes the
ip_do_fragment() frag_list fast path, each detached frag_list member is
transmitted as a standalone IP fragment and would still carry the stale
outer TCP GSO state when reaching validate_xmit_skb(). And even when an
ESP record does not have a frag_list, leaving the stale outer TCP gso_size
on the decrypted inner skb prevents dev_gro_receive() from initializing
gso_size to the inner packet's skb_gro_len().

We cannot reset GSO state earlier in espintcp_rcv() / handle_esp() because
the skb is still a clone sharing skb_shinfo with the outer TCP skb held by
strparser. Instead, call skb_gso_reset() on both the head skb and each
skb_walk_frags() member at skip_cow in esp_input() and esp6_input(), where
the head skb and all frag_list members are guaranteed to be uncloned with
private skb_shinfo.

Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)")
Cc: stable@vger.kernel.org
Signed-off-by: Guoshuai Yang <yangguoshuai@gmail.com>
---
v2:
  - Also call skb_gso_reset() on each skb_walk_frags() member at skip_cow
    in esp_input() and esp6_input() so detached frag_list members on the
    ip_do_fragment() fast path do not retain stale outer TCP GSO state.
  - Specify target tree 'net' in subject prefix.
  - Link to v1: https://lore.kernel.org/netdev/20261018005218.53267-1-yangguoshuai@gmail.com/
 net/ipv4/esp4.c | 8 ++++++++
 net/ipv6/esp6.c | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index e76db58..012b59f 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -900,6 +900,14 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 	nfrags = err;
 
 skip_cow:
+	if (x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP) {
+		struct sk_buff *iter;
+
+		skb_gso_reset(skb);
+		skb_walk_frags(skb, iter)
+			skb_gso_reset(iter);
+	}
+
 	err = -ENOMEM;
 	tmp = esp_alloc_tmp(aead, nfrags, seqhilen);
 	if (!tmp)
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index b1c9b36..b08cc1c 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -943,6 +943,14 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
 	}
 
 skip_cow:
+	if (x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP) {
+		struct sk_buff *iter;
+
+		skb_gso_reset(skb);
+		skb_walk_frags(skb, iter)
+			skb_gso_reset(iter);
+	}
+
 	ret = -ENOMEM;
 	tmp = esp_alloc_tmp(aead, nfrags, seqhilen);
 	if (!tmp)
-- 
2.54.0 (Apple Git-157)
Technical Details
Message-ID: <20261020030450.7170-1-yangguoshuai@gmail.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-349000-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-349000-linux-kernel-netdev=dewy.ru
From: yangguoshuai@gmail.com (Guoshuai Yang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2] xfrm: esp: reset outer TCP GSO metadata on espintcp input
Date: Tue, 20 Oct 2026 11:04:50 +0800
Organization: Usenet Network
Message-ID: <20261020030450.7170-1-yangguoshuai@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3772293"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VT2cfPm+7uR1NlH12V4T1tjkSCQ= sha256:zwO8Wsbr1DjNheWVpfy+xj6GgL33q2JigQiQW7BtHTI=
	sha1:l+wgi1yu9P0b1UatLPRNlBaXrnM= sha256:2m8CK5nyo5SJvgyZ2xbzSXp8b3txYVhXluRpTw8BE8s=
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 E3527110BD8; Tue, 20 Oct 2026 06:10:09 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, 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=gmail.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 4ZSvA9F5Ukn1;
	Tue, 20 Oct 2026 06:10:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-349000-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 72C1310FD25; Tue, 20 Oct 2026 06:09:51 +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 A428D2B557; Tue, 20 Oct 2026 03:05:02 +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=1792465498;
	b=2nEoBG5YZsHKClfONEL3mb1yVr/P4tCJylwrU4Hjmx07qwMHLJi4mRIvlUC0giJsAl8f
	 KNdImW3r6bEyVJ1kJAxyFOW18PRzBLKED7AFPEhrL3QOg8cGc2hoyU5biVsmDbGufL0FY
	 89XlaPd7OHXALbM1wFaesETeNzFUcY57WndotGr7ds029NSbfMwAO3Q8Go/z8nU5WJ9rU
	 u5JgyjxLIw5VtIcUjdblNqReSj4yzwE+5HjOnBqWTXbwHK6fwVFPOlf7d8BNcR4PUaKRC
	 sc89MbDrONp9DpYALcciNucY4l5LekQmrl095h/8oPGjPeNJXTsfb/h1cRaDRCua9/Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792465498;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received: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-Transfer-Encoding;
	bh=Pm54GtLoc9Ls0ofX4mP3XCN3sjH8BR9wUxBcQ7EXzFE=;
	b=D0mZ9FXPAMNQGhqnOTUDGqIo0NlOth5JebZuM0olhKGKtx395VFmqZ++vkI8q7MK43qD
	 KIshfDZbwq+0zAiSBvgtinyehq5S3hxy2t6OKHeq198iSQa4J/0H17vB8WxSp+SW1GzFH
	 HxByRPPpXjXW7dcLP5/3f3yU0e1yISSgtzQxzDlpTy32sduJLGhrFen/VDAmUNZNCkdkW
	 NtE8fiIPjc0S3u4tewEBe3fq3q1HPzP33saPNpuY/Xyggfod1+frwSFzs1p7/dn7nuwmQ
	 eIc0M2fnryL+RkBb8X4DnxC0MUTGm8SS3f1J6VgmeGbA6OWFmE/bSWdq1vGZZQ/sKiQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=fkj345uK;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.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 D4D13606A325;
	Tue, 20 Oct 2026 03:04:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=fkj345uK
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.42
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792465498;
	b=yddWUQPbQ2KiAnLR957IKZGmZ2Y4GtaXP4nGhcToa5dC70k6qvCHgztkHgCLpnquneDn
	 juQJjA1r6a9qevvE0+dS4wfu2Hlw3JlMUCaVfys6q9RssvcffycSz+SgpzOYi0uDFUnvt
	 kxyiOzJvGJBUi4XzNupYe11HypQiWJwsafrNCvHgjjpRMnMxuVP4AI3f4ABFN3gccYCCv
	 dMruxOWHyW5CPGxTZCR8T6n/7qDGgx8+QUguNaKd7uLRYA7nARlMELqj8qgZnBLia5Pv1
	 Yy2cSMPOpoC14rb2/1q16LCibO9dQSV4AdpklVjaWeIimOwHqq6AHcm2B0WmQMUG+tg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792465498;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Pm54GtLoc9Ls0ofX4mP3XCN3sjH8BR9wUxBcQ7EXzFE=;
	b=4inZ9YCvyM8SF3K5glY9BwobwL4eDMJcBNOFNchHdkfxZr5EanPPEy+psA3RYorX8aDV
	 H1TYytym8I0uzXxgY9JANhxH17ZcXyPVAuGVFPcOZW/nwljgny3aOOpbbODThoXhVOmWB
	 8qs3Q99UzKFikJnP4wG6y+JalDly5CLhIbZFi0ZYh/07RcA4TjB4kISYrzynvywQ7b41o
	 U6nsEhoSGA1yi1ac3s4eEH7bN9cLIKjxgl/IsMBRZ4JhWWLL2acRjU5B+rXXKPDKLMK0w
	 uJr4lj3KcOUWYlmxRJhNBSXs1puhfJnMk4OZExsREJkTEHJr+guR9EE0BxJGndX+yVA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=fkj345uK;
	arc=none smtp.remote-ip=209.85.216.42
X-Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4A0B606A31B
	for <netdev@vger.kernel.org>; Tue, 20 Oct 2026 03:04:57 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A4A0B606A31B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-38d489b6b71so1566625a91.0
        for <netdev@vger.kernel.org>; Mon, 19 Oct 2026 20:04:57 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792465497; x=1793070297; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=Pm54GtLoc9Ls0ofX4mP3XCN3sjH8BR9wUxBcQ7EXzFE=;
        b=fkj345uKHxlY1zp+L646DsGbiQCi4nncGEY+opVpYR1ADxZ7pgziCLhYFDqttQU8d6
         odIEkEVwT/kQHCYYKNBAfksIGO0FiP9VKFgjHEn6YGa5X8+RwsuwOtdN201t+wnsHRyL
         6JUEzjUU3XYuMTpf+CJ/wFp9eu3qlMcDHjjeWDHt5o+rOrVxnhV1roP6liSGzS4knz89
         JpNFXTG7f6gAuoDRAI0PNDCGr/Y5F7rO5zVvqnbpA81oaPMGgVJOPegW/NtcklIg8Ffz
         mhajwchBAyRtR9wIOA/3w2yyGp6TUB9l8Xd65pY5ZBaLxCMO1Pk4u8gW3Q5nu/RUkcCn
         dlFg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792465497; x=1793070297;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=Pm54GtLoc9Ls0ofX4mP3XCN3sjH8BR9wUxBcQ7EXzFE=;
        b=AArab9yUSbzsfLf6zqm2tQSQWXSIDelJbOxdzPui7cjZnvS9A18XQu7HVVpwwjxnvE
         x8/EluUMG15zrSkKJmKFLEeakh8piYvf3Q/7PXMcFMvCUeM8Q2w1CO720iwNBKiS/fcE
         7bxfT3U9aZeSBTEhoGbD4WyA6yw3iOXKgPU28WbSGs8Stv/hQpB4yA8zwCc2BrIvnBwG
         ro8Pbwk1ppWz/3VYEIcqdlqbiWqOVYRpLAgAUGYdY/tVYIQb/A6sKZ8MNEN1smzx+2sQ
         BSP/X5ekLoNdX7diZTWzQpF5St8TzRTZhTYLa0DTD1NdAHc0XAT+3J482PfOR2DdNZBX
         7pNw==
X-Forwarded-Encrypted: i=1; AKwUvByaTY8vCAWB2U1BdBlxeUFEjDZAfxtAXkseENFpkT9S/UPm/pE7cDLqKGHTw/WdKJHBjdj1LyY=@vger.kernel.org
X-Gm-Message-State: AFq9FYL3mJ4BU317VsLgKHbASgFvBvZVJS+r1jRe1PQcakhjYbule54Q
	lU/8SVLUej4T4fkReoEMRNhZc14ZdVgai8M0MwJFGTGAV9PeBVXERwnZ
X-Gm-Gg: AYBFou19Tl98thzo1xYY5yZKS5us71AsgprkPxjt801uPVxmXVHYRbBmFBaDrwfrj/5
	AgBv1EMk5qR2VgoW7V5+Ln+HyS5fye6WUaYE5r9SrmAQqHtA74gzNsoGBfr+flMdbNnIicwLC+E
	U34spEUyWitOrtgvmTLpqequToyC8rbgHtLIAWYUyZhjwyZek9Xit89qw7tDdS5osKwXonHF4AQ
	lknlmETX5GhkAQvf9VvM0neb9i/9MHe5JYDzfX0eEnvnzuFX2WOLAIAeBVlQt/LanmuqgzCKkQ0
	TcAs2zuAOxHKBj6uAaRawTz6RcT7weo/yDB6lsWpp1HBST995CrIfaiMKpsKrzAsOwa9gcBUfDk
	L7fNPDLfUDIyB9OZ2DQUeUFyonJChsCQ7BICJ5kDDmPaIIO7pp9NhsKUt5R7breX4lx9QRjBtT/
	Mjg2B1ix5NeC7KQ5xdOfc1BLbyj9QrgNlfI1DOF3Flmn/3N6SdFYM/vCvJcX4QimDgQR24MlzVK
	F5zSRqH70zWozn4Dz/dfPolYqhkVoEkj8pruzOfCJD9jjlOk6Pb/u/JNV2Q6fs=
X-Received: by 2002:a17:90b:3b46:b0:3a8:c0cd:57f3 with SMTP id 98e67ed59e1d1-3aceebc55e4mr7918127a91.18.1792465496890;
        Mon, 19 Oct 2026 20:04:56 -0700 (PDT)
X-Received: from localhost.localdomain (ip67.244-167-222.hkg.ten111.net. [222.167.244.67])
        by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3acd05c9255sm9545638a91.2.2026.10.19.20.04.53
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Mon, 19 Oct 2026 20:04:56 -0700 (PDT)
X-Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Guoshuai Yang <yangguoshuai@gmail.com>,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.54.0
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