From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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 ; Sat, 5 Dec 2026 19:20:52 +0000 (UTC) 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=ccJIw26y Received: by smtp.kernel.org (Postfix) with ESMTPSA id C29E41F0092B; Sat, 5 Dec 2026 19:20:51 +0000 (UTC) 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== Subject: Re: [PATCH net-next v3 02/13] ipv6: keep a superseded pcpu dst working until its holders notice From: netdev-bot+sashiko@kernel.org To: dsahern@kernel.org 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 Date: Sat, 05 Dec 2026 19:20:51 +0000 Message-ID: <179649845131.3148.2011766218783980294@kernel.org> In-Reply-To: <20261201174021.7211-3-dsahern@kernel.org> References: <20261201174021.7211-3-dsahern@kernel.org> X-sashiko-severity: Critical Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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