🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27265

[PATCH net] ipv6: avoid recursive routing header processing for VRF-local routes

#27265
From: Dickson Wu via B4 Relay
Date: Sat, 05 Dec 2026 02:39
100 lines
14982 bytes
From: Dickson Wu <dickson.wu@certik.com>

When an SRH segment names a local address on a VRF slave,
ip6_rt_get_dev_rcu() uses the VRF master as the route device while
ip6_rt_init_dst() sets its input handler to ip6_input().
ipv6_srh_rcv() recognizes local delivery only from IFF_LOOPBACK, so it
calls dst_input(), which re-enters the routing header receiver for each
remaining segment. ipv6_rpl_srh_rcv() has the same path.

On systems allowing unprivileged user namespaces, an unprivileged user
can create this setup and send a 127-segment SRH, overflowing the
kernel stack and panicking the host. An SRv6-enabled VRF slave can
receive the packet from a peer as well.

Take the existing iterative path when the route's input handler is
ip6_input(), while retaining the loopback test. Local addresses outside
a VRF already take this path, because ip6_rt_get_dev_rcu() gives their
routes the loopback device; VRF-local routes get the VRF master instead
and miss it. This applies the existing hop-limit check to VRF-local
segments in both receivers. Before decrementing Hop Limit, invalidate a
CHECKSUM_COMPLETE receive checksum so the transport layer recomputes it
from the changed packet.

A reproducer is available on request.

Fixes: 1ababeba4a21 ("ipv6: implement dataplane support for rthdr type 4 (Segment Routing Header)")
Fixes: 8610c7c6e3bd ("net: ipv6: add support for rpl sr exthdr")
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
Tested on net e9d78fc6741a in KVM, as an unprivileged user in a user
namespace:
- 127-segment SRH to a local address on a VRF slave, sent locally and
  over veth, and a 127-segment RPL type 3 packet: the base kernel hits
  the IRQ stack guard page and panics, the patched kernel survives.
- one-segment SRH and RPL type 3 packets with CHECKSUM_COMPLETE (tc ct
  action): UDP receives them with no checksum errors.
- tools/testing/selftests/net/srv6_*.sh: same results before and after
  (11 pass, srv6_encap_lookup_l3vpn_test.sh skips; the rpfilter match
  was not available in the guest).
- W=1 build, checkpatch --strict clean.
A two-segment RPL packet shows UDP checksum errors with and without
this patch; I haven't looked into that one.

This conflicts with net-next 47f89dfc930b ("seg6: update skb checksum
when ipv6_srh_rcv() decrements the Hop Limit"). The resolution is to
keep its update_csum_diff4() in ipv6_srh_rcv() and drop the
CHECKSUM_NONE lines there; the RPL hunk is unaffected.

This was found and the fix prepared with AI coding tools (OpenAI Codex
agents, with review by Claude). I went over the analysis and the patch
before signing off.

 net/ipv6/exthdrs.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index ccc549de3c8a..2e0d247366d2 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -459,7 +459,8 @@ static int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)
 		return -1;
 	}
 
-	if (skb_dst_dev(skb)->flags & IFF_LOOPBACK) {
+	if ((skb_dst_dev(skb)->flags & IFF_LOOPBACK) ||
+	    skb_dst(skb)->input == ip6_input) {
 		if (ipv6_hdr(skb)->hop_limit <= 1) {
 			__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
 			icmpv6_send(skb, ICMPV6_TIME_EXCEED,
@@ -467,6 +468,8 @@ static int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)
 			kfree_skb_reason(skb, SKB_DROP_REASON_IP_TTL_EXCEEDED);
 			return -1;
 		}
+		if (skb->ip_summed == CHECKSUM_COMPLETE)
+			skb->ip_summed = CHECKSUM_NONE;
 		ipv6_hdr(skb)->hop_limit--;
 
 		skb_pull(skb, skb_transport_offset(skb));
@@ -618,7 +621,8 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)
 		return -1;
 	}
 
-	if (skb_dst_dev(skb)->flags & IFF_LOOPBACK) {
+	if ((skb_dst_dev(skb)->flags & IFF_LOOPBACK) ||
+	    skb_dst(skb)->input == ip6_input) {
 		if (ipv6_hdr(skb)->hop_limit <= 1) {
 			__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
 			icmpv6_send(skb, ICMPV6_TIME_EXCEED,
@@ -626,6 +630,8 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)
 			kfree_skb_reason(skb, SKB_DROP_REASON_IP_TTL_EXCEEDED);
 			return -1;
 		}
+		if (skb->ip_summed == CHECKSUM_COMPLETE)
+			skb->ip_summed = CHECKSUM_NONE;
 		ipv6_hdr(skb)->hop_limit--;
 
 		skb_pull(skb, sizeof(struct ipv6hdr));
-- 
2.43.0
Technical Details
Message-ID: <20261205-ipv6-srh-vrf2-v1-1-422e7756101c@certik.com>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377852-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377852-linux-kernel-netdev=dewy.ru
From: devnull+dickson.wu.certik.com@kernel.org (Dickson Wu via B4 Relay)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] ipv6: avoid recursive routing header processing for
 VRF-local routes
Date: Sat, 05 Dec 2026 02:39:41 +0000
Organization: Usenet Network
Message-ID: <20261205-ipv6-srh-vrf2-v1-1-422e7756101c@certik.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2967851"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:hX9VnFPPQWhQ5zFZNCbr71Znwvc= sha256:ynzvH7X1KL90wjzyinTLU0mF2Q3UQVYB5wQIVOOa//w=
	sha1:O/LbuS9AMG2iKLzxuuYfLDZeFXA= sha256:uMcwMlIR/7/43L9QU4JsbnKo3xTsUWODnva063m/NXw=
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 B21C0117D83; Sat,  5 Dec 2026 09:24:59 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.566
X-Spam-Status: No, score=-2.566 tagged_above=-9999 required=6.31
	tests=[DATE_IN_PAST_03_06=1.076, DKIMWL_WL_HIGH=-0.142,
	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 4-HGbaJhnafg;
	Sat,  5 Dec 2026 09:24:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377852-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 1E6DE117D6D; Sat,  5 Dec 2026 09:24:49 +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 4E39C28A64; Sat,  5 Dec 2026 06:24:47 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796451887;
	b=W2GUGSA0IUU3yRowFpYrDZt73n4McSZd0wp38cgnm0DZUPy7hFjJp6E1f0iM3X6BvUYS
	 XNj90DiEwek1FemfC7dQ75Jo0Yj7fPngJml9c6EnL37vPcLPZSX0T4FD86AvkASvV2dS5
	 H1g2tDKeJELBkJNkSPUSKXcozayVBOmVKrSqd9qeIJCu5l1+FTqXpEZ628n01ZC+MSKEq
	 pVGuJ+ZG/T8+tuBHR8RrJSq5gRrFDxYQ4YCVzxvB+LjoMZ/kcgftm2F6QWIwXcnRGiAgL
	 tMUHt6Msqsle4lhhBLyFL33OhGi05Yp5r9O4ixZ3LZwc+EEsYnppv04ks4Xv6ic3oIw==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796451887;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Message-Id:X-B4-Tracking:X-Change-ID:From:Date:Subject:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=oTiNQHyCGyy3UgU8jW2EqQUnJteVvvfraqvYkmwk1GE=;
	b=z9oeEE8yNE19utKbJO1bjYn3muNSggNicV6lMyA8WuZV7HsClxDln4tUN5y6yRNHwaCr
	 zYwqZu4dL/YViy9IdH2302HtPEDBJfPx2CYHAUgKiCWhNHLHCc//UA4Cl6XkrfpVLaZOr
	 3NrnMD0r8S8cqDPQARbUKCUmIA/WACsaQkZ694oeCaqcCmjmUYR3nmZBOKZDUFLxT5aTT
	 GcGDWM6WbENjG+DMkS7oLcmnJ1vOVwwVmmFcFjaqECpsZ+X+8dcuAaklQOfjd626dl3xU
	 /+v1ezH7v7JpReD+5ULf802uQrSq7eJXSL1Y9oMH6erwWiaGiLUZ9rVpv8jmnW/Lc0Q==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZXTAQ9T2;
	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 13B07606A335;
	Sat,  5 Dec 2026 06:24:47 +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=ZXTAQ9T2
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796451886;
	b=myuRXdy2jHfMGdwFnNSmMtA0U6j9pGwSAS/doQSmjFozYaM1Z/3e0e+gFXEf4UKsDybw
	 wLGmL90woU/FJwJTI96/Xr95pwOlwFiHMh1Vm8eI1fJzBQr0WFezcootW36VJYbKGK3Cv
	 vU9PrPdJpp5ipozyvlirjySE4iEJpyNI98BxocRaa+UYK8LrpMEfIRVTRz5qb1Wi5yb98
	 T1aNNtC2CjiTwAacT64lO/a6vS9W5hqbIKu6wjEr5NLWF3nxjZBoCUib4Y3n/ZIIOFBRL
	 aSOjWVhPkXXQH8SyXSayaKzR23SeuCOv5XLead343gKDFepZp8iMJREjoCWj7CVGgCg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796451886;
	h=Received:DKIM-Signature:Received:MIME-Version:Content-Type:
	 Message-Id:X-B4-Tracking:X-Change-ID:From:Date:Subject:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=oTiNQHyCGyy3UgU8jW2EqQUnJteVvvfraqvYkmwk1GE=;
	b=XkNMGC2L7Lm1xLdI30EYFtRJTGVJcl6MM/+iJnGzgbptd9oobGDF5vJoCada52RV6BR+
	 2g0LwIXvnygYm0LlbgFHKMvWtDQqxwfDAVLvYG/992EQ4H9yJCmZ3Do1RBmD8Yjnsxnvo
	 QCyBDOWUV6yrZk/nJFHOyDv4QtQeuM4iYabNzEayIxYL4D9apKiPRxIEFN02GetCP08fd
	 WFDo2LwxRfzHuC9sRPaUW5Ew+fDEycNpYEwdlz7B0zfkjXa3x2AuKxBmWnQYpu5HzhvZh
	 UtX9GJtgtLchlOvAUvlK6vjehoH8In1fKDG1K3xzJpW9BecSlm6+6lOlNffWo9iUPKQ==
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=ZXTAQ9T2;
	arc=pass header.oldest-pass=0 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 2F231606A322
	for <netdev@vger.kernel.org>; Sat,  5 Dec 2026 06:24:45 +0000 (UTC)
X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77
X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none;
	t=1796451885;
	b=EM+6SgR8W0bYuTMAfdjrJpi16c9hpg2FuARZXUqlHkm9ONZN05Nc1lhggdsQV5W9lHOW
	 UnZh3elLhjnePbgRyILmVgKjVnQ7Cmvix5hhZAlpk19hc465kRjn/PGMEo3+QtW88340U
	 BulNLd72rM2d7AH3eQ9ri9cILDDxQnuIVGjDbL+/TRJfjPPC9xfxlsFOHm4/gG8O2dmUG
	 3Y6H1bDhrBCcetg+wyPXHIHSTwHlH0XMCdpZOfGwhIUFdhVv4jghIrcJDKWV5okLAUyKz
	 iZt+FLY0Ee9s1kY6+MYF3jyzHBYIlN4WVmkXJHv+x8WppoI151t6bYX6Lkv/lyMQxiw==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
	c=relaxed/relaxed; t=1796451885;
	h=DKIM-Signature:Received:MIME-Version:Content-Type:Message-Id:
	 X-B4-Tracking:X-Change-ID:From:Date:Subject:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=oTiNQHyCGyy3UgU8jW2EqQUnJteVvvfraqvYkmwk1GE=;
	b=a66Q+RCdS5TlryWp9LvsFiXXvE7CtMuMPtqmCak9lC17Znkpq0F4iUgBUQdNmjgD/u5k
	 hXGYZhLJ1zQo4SzOUiONULC7FlZTmcjkAawSvOtocnW4xWe8NQMNFA3taMVTLXkWkammI
	 v8e66sYPGqUSLn6Q1Pgubr8W7gDp5v+gqTw2GcJglS8pH0ZKm4U4p7e7/460NeDiZMoJv
	 OolZcgXjZXioQesOfle0m+50yyC9eE5Xzo0W4UXzmuOgP2W3z/1Ze/z7uxuFP/VDXxasT
	 2u7K25BIvMAQq9lm5lZE6IKbkSoLNHAzwtRGtdPyiU5RreuhfYzzWLF2GGxzsAnUHDQ==
X-ARC-Authentication-Results: i=1; smtp.kernel.org; 
	arc=none smtp.remote-ip=100.80.115.77
X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77])
	(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.kernel.org (Postfix) with ESMTPS id 36CC61F0092B;
	Sat,  5 Dec 2026 06:24:45 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796451885;
	bh=oTiNQHyCGyy3UgU8jW2EqQUnJteVvvfraqvYkmwk1GE=;
	h=From:Date:Subject:To:Cc:Reply-To;
	b=ZXTAQ9T2PP7GLbpRKnm9Il1oEcfDccafu/3cvPn3sLHr6FNrKlqv54RsbJFVNfzh1
	 tmhzikVNLba8aXVzkpZbglwA5nyIkpDioDzpG/xyaAMizZO6wsoNmFQcB8G+HVoHaB
	 /sIvJT38K82N7Bx3/t4/+Wr1dQmlmQoUNEwOZ0ThbdOR1xQCCIU1wrCwUs0M/p8G+h
	 Ully1YahZ8UxDgMo+x61rBlYT2xtpyJAKiJVsMC8uPcNWuysFdwkHYDREXbTq94pTj
	 qF+zH505zPb9qRU2eO7r53M7lSnN3CTkaWIPGRec7YokzMcw9jnv2GZPnli8JgPjrE
	 9L7fK9rGwXnvQ==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
	by lkml.kernel.org (Postfix) with ESMTP id BC924501BD;
	Sat,  5 Dec 2026 06:24:44 +0000 (UTC)
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=H4sIAC+tE2sC/yWMQQ7CIBBFr9LM2kkoKkavYroAOpUxBhoGiUnTu
 wu6fC//vw2EMpPAbdggU2XhFBuMhwF8sPFByHNj0EqbUasz8loNSg5Y86LRKHOxXvnj1ZygfdZ
 MC39+vTtEKjD9pbzdk3zppT5zVghdttGHroTiXFJ6Yfew71+Imz/8lgAAAA==
X-Change-ID: 20261205-ipv6-srh-vrf2-6067ac0c3964
X-Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net, 
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, 
 horms@kernel.org, david.lebrun@uclouvain.be, alex.aring@gmail.com, 
 andrea.mayer@uniroma2.it
X-Mailer: b4 0.16.0
X-Developer-Signature: v=1; a=ed25519-sha256; t=1796451631; l=4337;
 i=dickson.wu@certik.com; s=dickson-b4; h=from:subject:message-id;
 bh=hXo5W+sLPAm2Rx74bJgxe+PB55FM03BZFvhj4vhPDyY=;
 b=ws0UQY9/57/CSxfX2rjNNjMWKtLfinwDo7fbiwsmtIAiHg585CW5dnfFilKMLhwhrSt8SfF7H
 p8h1f+ag8ErDkcLy0V2trAas7u29ukJlmArRg3N4DjtFLGQJIHCQpXe
X-Developer-Key: i=dickson.wu@certik.com; a=ed25519;
 pk=fxH7FS4FdojeJSGLJzgKdfO51Rvr4EW30yinj2mc1vg=
X-Endpoint-Received: by B4 Relay for dickson.wu@certik.com/dickson-b4 with
 auth_id=1647
X-Original-From: Dickson Wu <dickson.wu@certik.com>
X-Reply-To: dickson.wu@certik.com