🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27476

Re: [PATCH net-next v3 02/13] ipv6: keep a superseded pcpu dst working until its holders notice

#27476
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 19:20
166 lines
13892 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 1 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Critical] net/ipv6/route.c rt6_get_pcpu_route() now calls
  rt6_uncached_list_add(prev) on a stale RTF_PCPU dst, which sets…
- [Medium] The patch fixes only one of the paths that dst_dev_put() a
  pcpu dst that may still be held.

--

ipv6: keep a superseded pcpu dst working until its holders notice

Before this patch, rt6_get_pcpu_route() called dst_dev_put() on a stale
pcpu dst of a route using a nexthop object. The patch puts the dst on the
uncached list instead. Current holders can keep using it until they notice
it is stale, and rt6_uncached_list_flush_dev() still detaches it from the
device on unregister.

> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index c41c5ca23fe12..31ebcf6652166 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1483,7 +1483,13 @@ static struct rt6_info *rt6_get_pcpu_route(const struct fib6_result *res)
>  		/* Paired with READ_ONCE() in __fib6_drop_pcpu_from() */
>  		prev = xchg(p, NULL);
>  		if (prev) {
> -			dst_dev_put(&prev->dst);
> +			/* Holders may still be using it until they notice it
> +			 * is stale, so keep it working rather than dst_dev_put()
> +			 * it, which would turn the packets of anyone who has
> +			 * not rechecked yet into drops. Device unregister
> +			 * detaches it like any other uncached dst.
> +			 */
> +			rt6_uncached_list_add(prev);

[Severity: Critical]
Can this unbalance the refcount on the pcpu dst?

In IPv6, a non-NULL rt_uncached_list tells the caller that it already owns
a reference, even for RT6_LOOKUP_F_DST_NOREF lookups.
rt6_uncached_list_add() documents this:

	/* Set once and never cleared: non-NULL marks an uncached route. */
	rt->dst.rt_uncached_list = ul;

NOREF lookups hand out pcpu dsts without taking a reference. Before this
patch, pcpu dsts never had the marker set. Now the marker can flip on a
pcpu dst that a NOREF caller already holds.

This sequence on one CPU looks possible:

process context
ip6_route_output_flags()
  rcu_read_lock()
  ip6_route_output_flags_noref()
    ip6_pol_route(..., RT6_LOOKUP_F_DST_NOREF)
      local_bh_disable()
      rt6_get_pcpu_route()      <- returns P, no ref, marker NULL
      local_bh_enable()         <- pending softirqs can run here

softirq on the same CPU, after fib6_sernum was bumped elsewhere
ip6_route_input()
  ...
  rt6_get_pcpu_route()          <- finds P stale
    prev = xchg(p, NULL)
    rt6_uncached_list_add(P)    <- marker now set
    dst_release(&P->dst)        <- drops the slot's reference

Then, back in ip6_route_output_flags():

	/* For an uncached dst, refcnt is already taken. */
	if (!rt6->dst.rt_uncached_list && !dst_hold_safe(dst)) {

The marker is now set, so dst_hold_safe() is skipped. P goes back to the
caller as if it owned a reference. When the socket or dst_cache later
releases P, there is one more put than get.

Wouldn't that free P while the socket, or some other holder, still points
to it?

The window runs from local_bh_enable() in ip6_pol_route() to the marker
test. Softirqs on irq exit or preemption under PREEMPT_RCU can land
anywhere in it.

The same marker flip looks like it affects ip6_rt_put_flags():

	if (!(flags & RT6_LOOKUP_F_DST_NOREF) ||
	    rt->dst.rt_uncached_list)
		ip6_rt_put(rt);

That would put a reference the NOREF lookup never took. Callers include
both versions of fib6_rule_lookup() (fib6_rules.c and ip6_fib.c),
fib6_rule_action_alt(), fib6_rule_suppress() and
seg6_lookup_any_nexthop().

seg6_lookup_any_nexthop() also uses the marker to choose skb_dst_set()
over skb_dst_set_noref():

	if ((flags & RT6_LOOKUP_F_DST_NOREF) && !dst->rt_uncached_list)
		skb_dst_set_noref(skb, dst);
	else
		skb_dst_set(skb, dst);

So the later skb_dst_drop() would release a reference that was never
taken.

Before this patch, the same race ended with dst_hold_safe() either
succeeding or falling back to ip6_null_entry.

This also seems to still be present at the end of the series.
rt6_dst_release_deferred() defers the slot's put through call_rcu, which
keeps P alive for one grace period but does not fix the imbalance. Also,
"ipv6: validate dsts against the netns route generation" applies the same
rt6_uncached_list_add(old) pattern to replaced exceptions, and NOREF
lookups return those without a reference too.

>  			dst_release(&prev->dst);
>  		}
>  

[Severity: Medium]
Should fib6_nh_release_dsts() get the same treatment? It still does the
sequence this patch removes here:

net/ipv6/route.c:fib6_nh_release_dsts() {
    ...
		pcpu_rt = xchg(ppcpu_rt, NULL);
		if (pcpu_rt) {
			dst_dev_put(&pcpu_rt->dst);
			dst_release(&pcpu_rt->dst);
		}
    ...
}

When a nexthop group is replaced, nh_rt_cache_flush() calls it for every
IPv6 member right after rt_genid_bump_ipv6(). The routes and member
nexthops stay live:

replace_nexthop_grp()
  nh_rt_cache_flush()
    fib6_nh_release_dsts()
      dst_dev_put()

The commit message describes the holders involved: sockets, tunnel
dst_caches, xfrm bundles and in-flight skbs. After this dst_dev_put(),
their packets would still go to blackhole_netdev/dst_discard_out instead
of the holder re-looking up the route.

The commit message's reasoning about device unregister would seem to
apply here as well. At the end of the series, fib6_nh_release_dsts()
still calls dst_dev_put(); only its dst_release() was converted to
rt6_dst_release_deferred().

Is there a reason this path is left alone?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201174021.7211-1-dsahern%40kernel.org
Technical Details
Message-ID: <179649845131.3148.2011766218783980294@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378100-linux-kernel-netdev=dewy.ru
References: <20261201174021.7211-3-dsahern@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378100-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v3 02/13] ipv6: keep a superseded pcpu dst
 working until its holders notice
Date: Sat, 05 Dec 2026 19:20:51 +0000
Organization: Usenet Network
Message-ID: <179649845131.3148.2011766218783980294@kernel.org>
References: <20261201174021.7211-3-dsahern@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3103171"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rWUOXmlvbX0xT6DaQeg95gE7wJY= sha256:3RedytUFMdpnMogG6xOCgjv+TOByZd6/V0f5lvHFkPE=
	sha1:A9VwXiySEc+qCmrKtzHiAmlzv5w= sha256:VH3R/IRkSaOlAqzQmQWzSHNB3duUhLzT+tuJN5pdRqM=
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 0EE1B117E97; Sat,  5 Dec 2026 22:21:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.539
X-Spam-Status: No, score=-3.539 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, 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, URIBL_BLOCKED=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 JKgUtITm8maq;
	Sat,  5 Dec 2026 22:21:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-378100-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 24EF6117E8D; Sat,  5 Dec 2026 22:20:57 +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 02DB7321F8; Sat,  5 Dec 2026 19:20:54 +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=1796498453;
	b=EFWRxj7jgkdFsLyRuCrXzKh/D8+iHYT6i3Cwix/JrHfGthDoPZIEgqeR9TXDWrECHdGp
	 Vqt58TgY/0uHzHr1ekRN+sAcFLp5xtgMLHpIM+UZh9grKMzCps+bu1kfNslKfzGBj2orD
	 XNbflcj67Yb8ZyfgZtdNX8v2fUA7zX6fpdxS3ujktuoeZZ69O8EDBWM7NQjweef19/c2f
	 OmmBaYl2M+uI011BoKwRL8t4CVlhyePNqMMbhYNd+jfdb3JyNETRHX9veXIbVfGAxoZuD
	 Am8KS45Lgx4lyvi/UNHf/WN7R/+lBhxcqOhYrVsqH103jEwn7S0p6UhX32k7RC4DtKA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796498453;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=QOdzFCqH0OsFwyVCVReUtLrmHhK6zyqXt/nTkWDzk9A=;
	b=m/JqVI5HHbHgP5zoaMYM1A5B9/rBT9nJJRL3aG5xdxg4L2y5MSZPa6Uve9rTf0QBeR0o
	 WrzwaDUbIyjsKZEQtuN7HgocSw/jZR1aq5AiX24hqen/Daa3+9+Djs4I/BSIihhPjXaF6
	 02fVGpUH0WfBGBElsCKWJ39RqWQJ/Uw6kS0MrTRJmYc2vJ4crtWQ2g7ty73u7lVFNYzhG
	 8VvV/HTdXHJlqkNYg9Djf98Qv5Sk90QfzLWCeAFSRA3no7hzFo0Aa+m1te/X8Pv0ckBEr
	 97lyCYnrhbo3aqQyPFhpyDYnVsgacu+OdjahiVl1CmZ9BepKNCW59uA8gXMMdLnZA7Q==
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=ccJIw26y;
	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 CE5A6606A333;
	Sat,  5 Dec 2026 19:20:53 +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=ccJIw26y
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=1796498453;
	b=jwO8euejrDPFHyi71rH9X6uO/wS7XE/Cs7lR8rvQDvkJFX7+CDn+LGEyD7AJHt9i5ggV
	 TAoc6o8bE9q955t9U8APDTT7184l9VOb3eflhqBsDLHqnpy+pXBKnN73GYlaaVXIKhz4t
	 Neq57OxnKM5FFC+nuhaUkL75ePi/wni4ExPcGiX6cVGtH5qeocrG/DBaTwuDsxYNecPIQ
	 OwJ2D1zv4PV5ioCbWpktxYA78oAnYvL8AmcrV5EQIGoXybEw7IyTRLARsNg/SeSupo3Hq
	 1gPGZBW8fTr01EuC2nEXbcr1f6wb7IZP49nwKShmNtoI3DQKKaucx7Nn9Av4JHP1T1g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796498453;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=QOdzFCqH0OsFwyVCVReUtLrmHhK6zyqXt/nTkWDzk9A=;
	b=BBuT+vmPSwvDxFVAsnd9dDlB6vU6WkIiQfZCdKtkv7IDelueoVwIS3qhmgnXtyQksLjy
	 6UCPovWsWwv2QVhkoJZ0KEIKUjjSX/Ey33pC/U/bgk02kpNrFj66zb3ADwAny7RJ9f6Se
	 EuLLPdIYmEn2hbLkMbAaeRo8gVISWf3diww9kiYSKsT7OLePjVSY8xJWrdUWmfFNF1slU
	 Cp2BV6Ap+t5w2/um8+BmzDGeB61XeCMI6K/RLUWKACJedDVtW4fdmnLTVVH8dNcVEFR7/
	 dJaB3aL1cO1Hji3uLN7bqWz36MHe/gcO/L1f7oYXG7zouTtQG9t4aXXEJPr1jmDB5HA==
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=ccJIw26y;
	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 EBFFD606A31F
	for <netdev@vger.kernel.org>; Sat,  5 Dec 2026 19:20:52 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C29E41F0092B;
	Sat,  5 Dec 2026 19:20:51 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796498452;
	bh=QOdzFCqH0OsFwyVCVReUtLrmHhK6zyqXt/nTkWDzk9A=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=ccJIw26yFoJyk4W3cnOS0ygfKOvWh1IYwfwWz/kMUoc9ZdJPBrocSxv0KB23ZJarL
	 u18kbuw6ihZq6wSQryN9c6s8fIadAyCKUsfdPR0Qx/iHQBl9DbFibLtmR7qGnXuHmD
	 2b+uDWRwE6j6Tp95ABjcNjvksXVo2Y+hw8G3is0lg/44DVLmGaHsMgwoaffIdt3Rq8
	 7/k4mJAIXdtOp2LA1qYX7lO5lLq2uZc8Syur2cbMZSvpVRB3RYtX2JGdRr0dlQAVlf
	 IgBgNfkY/F9I9UAtcybJbtWK6RHPKwJ4TS0GupzRwaoVmVdwgTQLUkC19fk8tAFfRr
	 2KgiLIhfkhgZw==
X-Cc: netdev@vger.kernel.org, idosch@nvidia.com, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 ralf@mandelbit.com, ja@ssi.bg, dahern@nvidia.com, noreply@anthropic.com
X-In-Reply-To: <20261201174021.7211-3-dsahern@kernel.org>
X-sashiko-severity: Critical
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