๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27381

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

#27381
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 12:31
149 lines
13566 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท 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).

- [High] The fix is incomplete.
- [Medium] The patch puts a stale nexthop pcpu rt6_info (rt->sernum != 0)
  on the uncached list.

--

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

This changes rt6_get_pcpu_route() so that an invalidated pcpu dst of a
nexthop-object route is put on the uncached list instead of being
dst_dev_put() when it is taken out of its per-CPU slot. The slot's
reference is now dropped after an RCU grace period, so that
RT6_LOOKUP_F_DST_NOREF readers are not left with a freed dst.

Link: https://lore.kernel.org/netdev/20261201174021.7211-3-dsahern@kernel.org/

> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 39bcfa1ce01b1..df4d670bcfa60 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1499,8 +1499,8 @@ 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);
> -			dst_release(&prev->dst);
> +			rt6_uncached_list_add(prev);
> +			rt6_dst_release_deferred(prev);

[Severity: High]
The commit message describes two problems with a superseded nexthop pcpu
dst:

  1. dst_dev_put() turns a dst that is still held into a discard.
  2. The slot reference is dropped without a grace period while
     RT6_LOOKUP_F_DST_NOREF readers may still be using the dst.

Is the same pattern still there in fib6_nh_release_dsts()?

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

On a group replace, this runs synchronously under RTNL for every IPv6
member of the replaced group:

replace_nexthop()
  nh_rt_cache_flush(net, old, new)
    fib6_nh_release_dsts(&nhi->fib6_nh)

The member nexthops stay live, so readers on other CPUs can still get to
their pcpu slots. Suppose the dst's references are the slot plus the
child reference of an xfrm bundle B, and B's call_rcu() is already
pending. Can this sequence free the dst under a NOREF reader?

CPU1                              CPU0
rcu_read_lock()
ip6_route_input() takes the
pcpu dst NOREF from its slot
                                  fib6_nh_release_dsts()
                                    xchg(ppcpu_rt, NULL)
                                    dst_release()     /* 2 -> 1 */
                                  B's grace period ends; it does not
                                  cover CPU1's read section
                                  dst_destroy(B)
                                    dst_release_immediate(child)
                                                      /* 1 -> 0, freed */
uses the dst

On a single nexthop replace, replace_nexthop_single() swaps nh_info. Then
nexthop_put(new) reaches this path from an RCU callback:

nexthop_free_single()
  fib6_nh_release()
    fib6_nh_release_dsts()

The grace period problem doesn't apply there. But wouldn't dsts still
held by sockets, a tunnel dst_cache, xfrm bundles or queued skbs be
blackholed, just as the commit message describes for
rt6_get_pcpu_route()?

A nexthop replace looks like the most direct way for a nexthop pcpu dst
to be superseded. Should fib6_nh_release_dsts() also use the uncached
list and the deferred release?

[Severity: Medium]
Before this change, dst_dev_put() set dst.obsolete to DST_OBSOLETE_DEAD.
Now a pcpu dst with rt->sernum set goes on the uncached list, and its
obsolete stays DST_OBSOLETE_FORCE_CHK.

When the device later goes down or is unregistered,
rt6_uncached_list_flush_dev() does this:

	rcu_assign_pointer(rt->dst.dev_rcu, blackhole_netdev);
	...
	from = unrcu_pointer(xchg(&rt->from, NULL));
	fib6_info_release(from);

It does not change obsolete or sernum. ip6_dst_check() then returns early
for dsts that have a sernum:

	if (rt->sernum)
		return rt6_is_valid(rt) ? dst : NULL;

So the rt->from check, which rejects other flushed uncached dsts, is
never reached.

rt6_is_valid() compares rt->sernum against
rt_genid_ipv6(dev_net(rt->dst.dev)). After the flush that is init_net,
because blackhole_netdev lives there. For a route in a non-init netns,
ip6_rt_pcpu_alloc() took rt->sernum from the original netns. Every netns
counter starts at 1 and goes up by one per FIB change.

Can the stale sernum equal init_net's current fib6_sernum? If so, would
ip6_dst_check() accept the blackholed dst? The socket, tunnel dst_cache
or xfrm bundle holding it would then keep sending into blackhole_netdev
until init_net's fib6_sernum changes.

The commit message says rt6_uncached_list_flush_dev() detaches the dst
"like any other uncached dst", but other uncached dsts have a zero
sernum. Does the flush path, or the move to the uncached list, need to
clear rt->sernum or mark the dst DST_OBSOLETE_DEAD?

>  		}
>  
>  		pcpu_rt = NULL;

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796382820.git.ralf%40mandelbit.com
Technical Details
Message-ID: <179647386221.3146.9662783054271208111@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377988-linux-kernel-netdev=dewy.ru
References: <f595ecd06c4bb9dedaedaa5205b05bd46702d837.1796382820.git.ralf@mandelbit.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377988-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 2/2] ipv6: keep a superseded pcpu dst working
 until its holders notice
Date: Sat, 05 Dec 2026 12:31:02 +0000
Organization: Usenet Network
Message-ID: <179647386221.3146.9662783054271208111@kernel.org>
References: <f595ecd06c4bb9dedaedaa5205b05bd46702d837.1796382820.git.ralf@mandelbit.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3025016"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Z0ywOYePeuILp3qHlZYbq25hOGk= sha256:kDmEF0tTksoqTC7bWB7d9BPwIrEQPbSS+l1Tj8n89QA=
	sha1:TqFno8b6CYbV0jM+ZtxdALyyjqM= sha256:tjydUEWPV3ZmREv3sxJXxowpIhBC1/bQAU34y/bqB/U=
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 DD865117E1D; Sat,  5 Dec 2026 15:31:29 +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 FuXSGii1BK1C;
	Sat,  5 Dec 2026 15:31:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377988-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 17968117DEA; Sat,  5 Dec 2026 15:31:17 +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 05A5A34535; Sat,  5 Dec 2026 12:31:11 +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=1796473869;
	b=0Gz+O7skm9BcuTA6Z3QsNH+dh3Jy+JXqkF/Z7ZfTOmnqUp2NVulWKv+SOOybKQg/znJu
	 DLpXAtQJdfpSMr2IfWxzmJ76JrTRJtlNu0UfRBEPA3XFZvTzxgaMp/xkCJ24+fgZwsLHM
	 PdfeoctJPUGjdyFJ/MHE9OInxIAFT1WLDFDzXOFoVe8lNDdbhJswtO5QKSf4tR8PJMRAe
	 zw4eviD0d8pRNXJ2hQJ0wJKyS5KHK641vGn6Lvw/uasIic4ShgVpqrOiCaOk3lgJyjCvn
	 N6r2zqfCsVSCC1yUddm2H5E+NqalD7zMNq8COkFrZv/kXB79SzpdBcY9hbXwX5swNTA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796473869;
	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=uGkaye+bQDv3ziH5RqrxHmxM0FFezopKNJ6DpHcqq+g=;
	b=seZJ1i2lV4a2adqwwHPDVyvcikM2jOFJPNmp4lZtDNeKhhr53ijAb2POmK/LYaJbrUd/
	 FX5BLlrXdCZheh7fODNSP91sQE/kJICs9IDE2CcPjBI/B8R2JpKqWmb5+MZ6cXJQmCtUd
	 O5GaNXQuuDXmudhm2dSNKdhJCZOFCafWICK0AiTkwx0a4HG6sOF4TD2p522ieZqxEsZWk
	 cml6GClSHEKJWtsHSaQtwOhldXDf8Ijry2fbIvD/PpHXvBnrThe+3HzQ2cZSb7ElJNEtJ
	 HFCHRNFC+v9MxB0mkzvMADgFC75SU4KVi8sBmmpVXtRMe9Qruf1Zxmb/BMtVleUoT2w==
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=hLUryvkF;
	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 93E83606A33B;
	Sat,  5 Dec 2026 12:31:09 +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=hLUryvkF
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=1796473863;
	b=NCfp0toolgasVIw3jiCr5/hMoznbA+w87jjA9tLljeUB71iAYhUySdR/kA33VTDupOff
	 9YnLGsjp/0LdGY3o98OnovCqbDMV2Rt1CLOsKfNxgt2pSncKCvyHrfTb6WX+BfsbFBsRS
	 JYavmj0oIGlv3E4r6Mr+ilqCCOgWedsXh0/m3BgZWCHM8/U7rXsmjb+8X9pcVdbUTsNbz
	 nCStF4wasR66/CzH3hhmyBs0uBmw7yBXZzSniPeCKWuCRKYXauohjW957WHH6hRM9nCXe
	 iEccpwEwcfawQmONFP0us1vRPvuq/akyKiROVIkrcmHfe26yoIR3pmsJOrM8HpBCyeQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796473863;
	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=uGkaye+bQDv3ziH5RqrxHmxM0FFezopKNJ6DpHcqq+g=;
	b=K2hszCe5ybptl2BUxGxGGUFT+w8Jf8VGZW5Uo1sfFqsSdHCnIryeMMuUg7fb6SvTkxl1
	 byaG3yG3r812XyUKmV3rxZCKTVijM3OzV+ajv3v4Fawlqu1by7FbcIP5ev7u2S3/rKcNd
	 Gb4uP6+VGw7HuF6P3sMCepnkqSP4EbACwBmmhlOowxQFGQqWoiZGEe2KiivgoEeNJKlrx
	 kqoT9nmpH0Lye/O2FP2MUXkPU4EI7BKlaoXWGIcwFC0pJmHOJANd2+e9a+IT3vi1Wmk/t
	 ruSe9HV2yHaauzeiLscV63YiVuUcBvT+gFh8D38NV9rEBvz22lixg39ZkVg7eWnSQ1g==
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=hLUryvkF;
	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 B21E3606A334;
	Sat,  5 Dec 2026 12:31:03 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D3ED1F0092B;
	Sat,  5 Dec 2026 12:31:02 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796473863;
	bh=uGkaye+bQDv3ziH5RqrxHmxM0FFezopKNJ6DpHcqq+g=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=hLUryvkF8AUcje2+opkohhTHXrF5VDW5fwEbwWv2igVC5LRaPhdXXOw4REymOtH2z
	 zU5sAzxGaN/UdXv/fSa1qHw9fOtYQZfo0373k8karpNh9DbRmXezuSP+pnOdIufTJj
	 tf6yEp6ra9NwW+1m1s03cpUkvHTM1K+kuhDaL8yJ+YteZt/aodbLMTGulvizARHag0
	 rRvTPoguuHRTwu7dE5gFZK02aWMnJfNbth03buEupr4O/rGv6hYCfKSC6po1rsWqWQ
	 PF/QArBKqLlrtLC/O9lniIq2Xf2tt0WT/S73dEzHn6Yrn4l8lViHKx0TwE7doPTQUn
	 9Vky41CpAYnnw==
X-Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 willemb@google.com, horms@kernel.org, linux-kernel@vger.kernel.org,
 dahern@nvidia.com, andrea.mayer@uniroma2.it, antonio@mandelbit.com
X-In-Reply-To: <f595ecd06c4bb9dedaedaa5205b05bd46702d837.1796382820.git.ralf@mandelbit.com>
X-sashiko-severity: High
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