🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10892

[PATCH net] ipv6: ioam6: do not modify shared tuninfo eh.nexthdr

#10892
From: Hangbin Liu
Date: Wed, 04 Nov 2026 09:27
67 lines
11077 bytes
From: Hangbin Liu <liuhangbin@kylinos.cn>

ioam6_do_inline() and ioam6_do_encap() stored the next header into
the shared ilwt->tuninfo template and then memcpy()ed it into the
skb. The lwtstate is used from multiple CPUs without locking, so
another packet can overwrite eh.nexthdr between the store and the
memcpy.

The packet can then leave with an HBH nexthdr that does not match its
payload (e.g. TCP labelled as UDP, or a local packet labelled
IPPROTO_IPV6). Set nexthdr on the per-packet Hop-by-Hop copy after
memcpy instead, leave the shared template read-only.

Fixes: 3edede08ff37 ("ipv6: ioam: Support for IOAM injection with lwtunnels")
Reported-by: Sashiko <netdev-bot+sashiko@kernel.org>
Closes: https://lore.kernel.org/netdev/179336082844.3134.1265197633714491521@kernel.org
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
The issue is reported by Sashiko. It was confirmed with concurrent TCP
and UDP traffic through a shared ioam6 inline route on a multi-CPU host.

Without the fix, a packet can leave with an HBH nexthdr that does not
match its payload (e.g. hbh->nexthdr=17 with a TCP segment after the HBH,
or hbh->nexthdr=6 with a UDP segment). With the fix, the same load reports
no HBH/L4 mismatch: nexthdr is written only on the per-packet Hop-by-Hop
header after memcpy, never on the shared tuninfo template.
---
 net/ipv6/ioam6_iptunnel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ioam6_iptunnel.c b/net/ipv6/ioam6_iptunnel.c
index cfb2c41634a0..b23f8a0cbaa9 100644
--- a/net/ipv6/ioam6_iptunnel.c
+++ b/net/ipv6/ioam6_iptunnel.c
@@ -276,12 +276,12 @@ static int ioam6_do_inline(struct net *net, struct sk_buff *skb,
 
 	hdr = ipv6_hdr(skb);
 	memmove(hdr, oldhdr, sizeof(*oldhdr));
-	tuninfo->eh.nexthdr = hdr->nexthdr;
 
 	skb_set_transport_header(skb, sizeof(*hdr));
 	skb_postpush_rcsum(skb, hdr, sizeof(*hdr) + hdrlen);
 
 	memcpy(skb_transport_header(skb), (u8 *)tuninfo, hdrlen);
+	((struct ipv6_opt_hdr *)skb_transport_header(skb))->nexthdr = hdr->nexthdr;
 
 	hdr->nexthdr = NEXTHDR_HOP;
 	hdr->payload_len = cpu_to_be16(skb->len - sizeof(*hdr));
@@ -314,8 +314,8 @@ static int ioam6_do_encap(struct net *net, struct sk_buff *skb,
 	skb_mac_header_rebuild(skb);
 	skb_set_transport_header(skb, sizeof(*hdr));
 
-	tuninfo->eh.nexthdr = NEXTHDR_IPV6;
 	memcpy(skb_transport_header(skb), (u8 *)tuninfo, hdrlen);
+	((struct ipv6_opt_hdr *)skb_transport_header(skb))->nexthdr = NEXTHDR_IPV6;
 
 	hdr = ipv6_hdr(skb);
 	memcpy(hdr, inner_hdr, sizeof(*hdr));

---
base-commit: c3e67bd82b9b9b1a5118f09a429ccefe2aab0741
change-id: 20261103-ipv6_ioam_lock-65102ca54908

Best regards,
--  
Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID: <20261104-ipv6_ioam_lock-v1-1-4f24c41b261b@kylinos.cn>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356335-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-356335-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] ipv6: ioam6: do not modify shared tuninfo eh.nexthdr
Date: Wed, 04 Nov 2026 17:27:23 +0800
Organization: Usenet Network
Message-ID: <20261104-ipv6_ioam_lock-v1-1-4f24c41b261b@kylinos.cn>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="3362581"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:aFZrUgWK5P8gwvMmuOxFR9sAHss= sha256:4nDYDKli2g/IgvzZfaHg0aNieesqmNQI3oEcoycLyAY=
	sha1:5Yd8pVzBdbMLxDdBboQuqQmqC3A= sha256:339bf/JMUxM1Xj0aRvSsN4LAXQom6o8HVsj1pPWiPYo=
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 5BBAD112B68; Wed,  4 Nov 2026 12:36:27 +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, 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 (1024-bit key)
	header.d=linux.dev
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 ho6L1zBIvo9f;
	Wed,  4 Nov 2026 12:36:23 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-356335-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 1D5CD112B55; Wed,  4 Nov 2026 12:36:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id AF41A34C09; Wed,  4 Nov 2026 09:27:55 +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=1793784459;
	b=dCUTBv4A21En3NM+FTaGnv+q67oE7CBxhQkqBaG8m8hj/HzG6hz9yvOmPD7RK2BZiCvC
	 r9p+JAWrmGrpzAkYSSFffiFhlF4YohZQ2MmFbncw35DCJsadZKL86TOGKhXx/677jLqSK
	 FPnsQ+hhadrDUfRQih+GhYStSPpSPMHNBEGaMfs3gJXDNrWUktGeDgprDbX6UkMxSb5mi
	 Mc6ry9WIrxufuiFNNJc8Yz5UKiaRFF6akABTXRzqJeLmJ4RK3GojFnt4PS9aKFgObufkD
	 5x8xBNOud7cijlbtRH8O4fIYQr4txHCfapJRloKqoGUDR0pEiuyfWJTdKS47aiYEO9Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793784459;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:
	 Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:
	 X-Mailer;
	bh=n9KVR6E0wEE3Z1SX32MeaGZYTyg91eegU950Grgc2zM=;
	b=G+NvuLq8nAWUunIAHmhMzVXNTQuXniyOM/sW9wipvfGYbY/c+1ovr0xQEh5GHlIA75oY
	 hAeeCyCeZziALUu/WoD9yHjB5W5JYGdp6DoYieqtmQ5+QQvKR2D186IKm1yKVpTSor7i5
	 KuVdrmZDoBhWOh+im2+4ST/ykwk+xuc4bU1Bc55ejZjEg2/en2ZT2EryH9LJIr0GcvmCz
	 a/pInwvI9bL9f650pCF4QYKQGhwYPtDepHxLQ//9b1P3bt59zLcXCKF5+gyMJ8yqZuUV1
	 VRJkFlGhmsRhpRrv3SB8Ymqlq17FT2guiri5S2ZUAV19EH7ItPfGDHoLhGFOo1Hk5zg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="D/wlJX2F";
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 A36A4606D810;
	Wed,  4 Nov 2026 09:27:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=D/wlJX2F
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.200
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793784458;
	b=AaakThGoupoXE/4ixUOO6bjE9huBumVPjNITYCBdYIUwHE//yKGKIr0bHjG0CJdtthjQ
	 seVjCEzJnUwI6/NOin7+A6FCnnE0Kxnxbdb7J7MtYmGSYZTjRSc0Z8XI/A6HCe1qNllev
	 +wmRa/lEACKIBTz4b8FnEVPCEVZciiX5c15CDaMlRadzOfl/XiOfgIyjoFi4AFCUOYzjg
	 UkdtpbbY7hjIxo4bIHR6UbVpXeNW7FWhNJ4wZ5d1MviNiJR+6FAsuWkx76ICimM2zg8iz
	 OHx4GY7z36D2IcacLohXsqRCzbthRBNM9GvamdA+ASDn9vPhBuP4naOYNeA7akooQCg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793784458;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:Subject:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:Message-Id:X-B4-Tracking:
	 X-Change-ID:To:Cc:X-Mailer;
	bh=n9KVR6E0wEE3Z1SX32MeaGZYTyg91eegU950Grgc2zM=;
	b=cH0bH5Ly+pounJPut4nS8LjtGXUgZWhWen96wV0RiEpCx8EaaGayTk+AmroimVrzabZn
	 DQqCEPfE2l9IMjf/S4h9gagEhaGD1AxtWzT+vUfBvQ/lt/epxfcGs1HiUv54t/pJs6zWT
	 669DMQxkGHtEm7siaOZB3+bT75ntDtq92vbn7omuURTBsNskmaHVMLS5j6nHxG0FzBLYC
	 VrDLiEDHL4KtSQVzZiomoPsB1mCvZePwFNW0COWJNmuxaVD49O8JrFRrAxpIGRDukL48R
	 /4wOfSKF/LzSSn0p5UD3+uI/g9lZ1AUikPEGHJ0dbLsr1eYLRHYfEeuBIRuSKDsX+tQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="D/wlJX2F";
	arc=none smtp.remote-ip=91.218.175.200
X-Received: from mta0.migadu.com (out-200.mta0.migadu.com [91.218.175.200])
	(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 25370606A32D
	for <netdev@vger.kernel.org>; Wed,  4 Nov 2026 09:27:37 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 25370606A32D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=EfkSQXB6pzLCCxjVLJgFvVH/HoenBethMWU3Rt+A2wg=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793784456; v=1; x=1794389256;
 b=D/wlJX2FYTRRD3j0lO+nolV4LuRpvs0Du8i9sSBkvNJxakDQc/kN+15aZ32aQ3obLajG2RQj
 O28czYu+yPRtP/Q7ODQ+Kfg3BXDPehKABKgMWGES30fg6UzySq+jZUK9lmx8O0iv4KK7W6Vne/W
 BLq4s5ZluGb8sjklgIt65GBc=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta12.migadu.com with ESMTPS id f1cadc94103e3a01;
	Wed, 04 Nov 2026 09:27:36 +0000
X-Mizu-Trace-ID: f1cadc94103e3a01
X-Migadu-Flow: FLOW_OUT
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-B4-Tracking: v=1; b=H4sIAAAAAAAC/yWM0QqCMBhGX0W+awfbymG+iois9Zd/5TY2k0B89
 1ZdngPnbMiUmDK6akOilTMHX0DVFdxk/Y0EXwpDS22UkgfBcTUjBzuPz+AewjRKameb40m2KFF
 MdOX3b9jD04LhL/PrfCe3fFfY9w+UmUlFdwAAAA==
X-Change-ID: 20261103-ipv6_ioam_lock-65102ca54908
X-Cc: Hangbin Liu <hangbin.liu@linux.dev>, netdev@vger.kernel.org, 
 linux-kernel@vger.kernel.org, Hangbin Liu <liuhangbin@kylinos.cn>, 
 Sashiko <netdev-bot+sashiko@kernel.org>
X-Mailer: b4 0.16.0