🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12211

[PATCH net] udp: check frag_list IP family before using skb_segment_list()

#12211
From: Eric Dumazet
Date: Fri, 06 Nov 2026 14:17
56 lines
9869 bytes
From: Kyle Zeng <kylebot@openai.com>

UDP fraglist GRO uses SKB_GSO_UDP_L4 for both IPv4 and IPv6.

__udp_gso_segment() reuses the frag_list skbs when the geometry of
the head skb was not modified. skb_segment_list() keeps the network
header of each frag_list skb as it was at GRO time and only adjusts
the transport header offset.

Nothing guarantees that the head skb still has the IP family of the
frag_list skbs: helpers like skb_mpls_pop() let the caller choose
the new protocol. In that case __udpv6_gso_segment_list_csum()
handles the 20 byte IPv4 header of each frag_list skb as a struct
ipv6hdr, and can write IPv6 addresses beyond its linear part.

Check the IP version of the first frag_list skb. All skbs in the
list belong to the same flow, so they share the same IP family.
Use the skb_segment() fallback on a mismatch. Regular fraglist GRO
traffic keeps the fast path.

Fixes: b936a9b8d4a5 ("net: ipv6: fix UDPv6 GSO segmentation with NAT")
Signed-off-by: Kyle Zeng <kylebot@openai.com>
[edumazet: simplified the fix, rewrote the comment and the changelog]
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
This was found by an AI code review agent.
The issue was not triggered, no reproducer was provided.
The fix was tested with tools/testing/selftests/net/udpgro_fwd.sh.

 net/ipv4/udp_offload.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index cf07c3c6611a22c29b57a72420f2f940609f5e9a..802365b4780fdf7dc19ea7374d51d713e4eb736a 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -514,9 +514,14 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
 	}
 
 	if (skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST) {
-		 /* Detect modified geometry and pass those to skb_segment. */
+		/* Detect modified geometry and pass those to skb_segment.
+		 * SKB_GSO_UDP_L4 is used by both IPv4 and IPv6: also make sure
+		 * the frag_list skbs still have the IP family we segment for,
+		 * as their network headers are not rebuilt.
+		 */
 		if ((skb_pagelen(gso_skb) - sizeof(*uh) == skb_shinfo(gso_skb)->gso_size) &&
-		    !(skb_shinfo(gso_skb)->gso_type & SKB_GSO_DODGY))
+		    !(skb_shinfo(gso_skb)->gso_type & SKB_GSO_DODGY) &&
+		    ip_hdr(skb_shinfo(gso_skb)->frag_list)->version == (is_ipv6 ? 6 : 4))
 			return __udp_gso_segment_list(gso_skb, features, is_ipv6);
 
 		ret = __skb_linearize(gso_skb);
-- 
2.53.0
Technical Details
Message-ID: <20261106141727.2303218-1-edumazet@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-358031-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-358031-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] udp: check frag_list IP family before using skb_segment_list()
Date: Fri,  6 Nov 2026 15:17:27 +0100
Organization: Usenet Network
Message-ID: <20261106141727.2303218-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3899240"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:QhxzDzeyaKFwUIPEL7NOWm6kfeY= sha256:JXK5W6bAAezZzzyYVUtu/b6nCcIkqye8sNLqmZVGiHY=
	sha1:wHJjsS4HL9x6CMtrzp4vf25rl/c= sha256:xeW7TC0qdz4Dz4lH3+3H1DmRIxCQ6OB53IUWpnGOzRo=
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 9F891113280; Fri,  6 Nov 2026 17:20:51 +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 FLgUhKb1fegK;
	Fri,  6 Nov 2026 17:20:47 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358031-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 48F6A11327D; Fri,  6 Nov 2026 17:20:39 +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 7782C33AB5; Fri,  6 Nov 2026 14:17:36 +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=1793974653;
	b=f4Rj4mDZAukNpFLqVm8pUtS4S8JwsHDLOeeOebjMS03ZvI+zKDqevMy2Gp+C54jlpmka
	 iGIWJqGwXHyBVnYl00LJPQ1goaHM+WTTIQlNmLCp92prnI4h06CEDX+DWx5svEOcMdYt7
	 Xu9SEYk2YhO8Rk4H9v2p8YfwTHMZcLFg3e+i3m8IWLImaVLzwAvWu22X7lVYqspYX0ocj
	 FwB/g0rLOz9QAiuwAmON/sbXQjgovnpfDHztVCI+oSDivbjzzCy4Sh1odfi5cxHANqXQJ
	 yL1FEBpVYM4ksM6NKavOwth/SWpbyPedag88O2R2qarnEeMwcyvKKlDfdyruJxMsMRw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793974653;
	h=X-Original-To:Received:Received:DKIM-Signature: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=dgU4K6jypQRq1j+ccJv6VGA6lIRv41Ji69kDadDpuPo=;
	b=ExfgOLc3viklWSpazC+Pm7cx0WW3btZ6iMGa/sZJbTkFf9Jg3B2igyDFDNU+w0giaTB/
	 6kQ17MshCsWapaoJ/DJ6FNEc0+1MmxvHtIrtXeNdRB9JbWCJHvSVeZHLynq5qGCln8rkp
	 EepQ18U42HzcfobjXSHRu7a73+kuZFxPKfOCQdf0QbaWcosuLgOyKPzcx4ozGR6iapB+U
	 whrjIC1q4vsYvOkkQmw7sTP2ITZ0meDDmhJeNMPA3eedPBqwhhRyZfzLfCuZo5UOgZn0M
	 7EwEORIHdhzxhYy6PY+HwKzRndjc92DeA/4aJJmwzsPYIKzgN/Jh5HDu+c9Hqu5jRGQ==
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=crkkAHmX;
	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 317CE606A33A;
	Fri,  6 Nov 2026 14:17:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=crkkAHmX
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=1793974652;
	b=PcuYomvT6hu/Q70sZ8uJcJ7XA/rmT2NAbtBlIOlZb+P7Sdlq1+sTro1+YLF4pLOepFqE
	 FOH2qN0njJmcVIcRGqRx8Z0hAkSmKqxT9qt9k4tUAHG1EbcEkDvKEsOU8TiLapyqKG54y
	 8NzEroq1lomP8uobwAQ18Q40/7MNz+zZE0dl6HwXZg40Dhd8pw5pU2tdyTSfwc94NBeQL
	 amLgL28pzj0zoDfoEvB1Zl0wYFVFxw2vD7WiGMmZojGqs19APUwFObHV1VO7A5Qqmv7xV
	 oMJPdnHmV00FdY0kjVtk2nZDVFii3wAeDRB37vsAHFUwGHUJHviG+DrlILMTapijTOw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793974652;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding;
	bh=dgU4K6jypQRq1j+ccJv6VGA6lIRv41Ji69kDadDpuPo=;
	b=jLrzlWujySUHhITTyYLtLaa/aUwcPt+lDJ1RvMXAC/Vx349sIZ0sYFA3x8ZQdxdX8KM9
	 9l2rol4rj5t5FyNrLhLudGG5afaQsau2BhihKAeYWT2OcMMCzK6gZgscFkwzBSufOoLDb
	 KzShGJDebSQwlZekibXO5VQJsvhmiadHA0dkYclpLRpxzEMLSw11CWUaMT14GhD79T7Al
	 p04NRa5p2zz+Fvm3UTEGbJohcWE+DVCFKR/56lQgI4jXK2oFachHxX6W18vz45jfdSn1W
	 yLhGlnvJ7f1RsYWs7jL9YEEN3t5EThPsvNpYSq4VOukVA2a1uoOeny6zRJ14xseZErg==
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=crkkAHmX;
	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 1419D606A329
	for <netdev@vger.kernel.org>; Fri,  6 Nov 2026 14:17:32 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 031E81F008A1;
	Fri,  6 Nov 2026 14:17:29 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793974651;
	bh=dgU4K6jypQRq1j+ccJv6VGA6lIRv41Ji69kDadDpuPo=;
	h=From:To:Cc:Subject:Date;
	b=crkkAHmXuYFacvKzL9mhWCffs5WnubNXiTwhe0v9aTpvUhs7sDJfQyKrG2cyZyvcv
	 T+81N6e7ND+Ar1ieq5BLym/0ySLo9kxDq9d87HplM/hhdQXMjw1B67QkhD9Sv+ZaCZ
	 Mz89g++i+fwJWH3RKnOLA3ounpXvAzT4maA+lsMoAvSiAvX+7kr/UpywL7DZt61k00
	 2f9Rsv/tLWvNTYV3PgblEKtnn/w5/R8lazwG+14POhmjxhvqX1BK7uS+Ugxjpt5e+i
	 u4SoBPI9sVdDa6GggSZiRaxzEZvaEoD838S40iLeoZkhWUvzUESMo3UfPzsgykD9n9
	 NfVHYZLTcBCWQ==
X-Cc: Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org,
	Kyle Zeng <kylebot@openai.com>,
	Eric Dumazet <edumazet@kernel.org>
X-Mailer: git-send-email 2.53.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