Article View: linux.kernel.netdev
Article #25081Re: [PATCH net-next v2 06/13] ipv6: validate dsts against the netns route generation
From: Ralf Lici
Date: Tue, 01 Dec 2026 08:32
Date: Tue, 01 Dec 2026 08:32
51 lines
10176 bytes
10176 bytes
On Mon, 30 Nov 2026 12:31:58 -0700, David Ahern <dsahern@kernel.org> wrote:
> On 11/27/26 4:03 AM, Ralf Lici wrote:
> > On Wed, 25 Nov 2026 18:33:32 -0700, David Ahern <dsahern@kernel.org> wrote:
> >> @@ -1476,7 +1483,11 @@ static struct rt6_info *rt6_get_pcpu_route(const struct fib6_result *res)
> >>
> >> pcpu_rt = this_cpu_read(*res->nh->rt6i_pcpu);
> >>
> >> - if (pcpu_rt && READ_ONCE(pcpu_rt->sernum) && !rt6_is_valid(pcpu_rt)) {
> >> + /* A dst stamped with an older genid stays stale for everyone still
> >> + * holding it, as in IPv4. Never re-stamp it; drop it and build a
> >> + * new one.
> >> + */
> >> + if (pcpu_rt && !rt6_is_valid(pcpu_rt)) {
> >> struct rt6_info *prev, **p;
> >
> > This now evicts the pcpu dst of every route after any generation change,
> > and the eviction still drops the slot's reference right away
> > (rt6_uncached_list_add and dst_release from 02/13). A reader that took
> > the dst from the slot without a reference can then see it freed, when
> > the only other reference is the child reference of an xfrm bundle:
> >
> > 1. Bundle X, whose child is the pcpu dst P of CPU0, drops its last
> > reference, and dst_release queues dst_destroy_rcu.
> > 2. After that grace period has started, a lookup with
> > RT6_LOOKUP_F_DST_NOREF on CPU0 gets P from the slot inside its RCU
> > section, and is preempted (PREEMPT_RCU) before dst_hold_safe.
> > 3. A lookup on CPU0 after a generation change evicts P and drops the
> > slot's reference, so X's child reference is the last one.
> > 4. X's grace period ends without waiting for the first lookup, and
> > dst_destroy(X) frees P with dst_release_immediate.
> >
> > Mainline only evicts nexthop-object dsts this way, and
> > fib6_nh_release_dsts has the same pattern, as Sashiko pointed out on my
>
> I do not recall that being intentional. If anything we want consistency
> across built-in nexthops and separate nexthop objects.
>
Ok but the objection is not about the eviction itself. The issue is how
the slot's reference is dropped: lookups with RT6_LOOKUP_F_DST_NOREF
rely on RCU to keep the pcpu dst alive, and dropping the slot's
reference right away breaks that when the only other reference is an
xfrm bundle's child, since dst_destroy releases the child with
dst_release_immediate. Dropping the slot's reference after a grace
period, from a call_rcu callback, would fix it for both kinds of
nexthops, and in fib6_nh_release_dsts as well.
--
Ralf Lici
Mandelbit Srl
Technical Details
Message-ID:
<20261201083252.37868-1-ralf@mandelbit.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374848-linux-kernel-netdev=dewy.ruReferences:
<cover.1795642432.git.dahern@nvidia.com> <52846eb18319fc2841ffa6dbb32abcc898eca8df.1795642432.git.dahern@nvidia.com> <20261127110319.354669-1-ralf@mandelbit.com> <88b0bd75-fb61-4469-a98f-6e30b3a63824@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374848-linux-kernel-netdev=dewy.ru From: ralf@mandelbit.com (Ralf Lici) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v2 06/13] ipv6: validate dsts against the netns route generation Date: Tue, 1 Dec 2026 09:32:52 +0100 Organization: Usenet Network Message-ID: <20261201083252.37868-1-ralf@mandelbit.com> References: <cover.1795642432.git.dahern@nvidia.com> <52846eb18319fc2841ffa6dbb32abcc898eca8df.1795642432.git.dahern@nvidia.com> <20261127110319.354669-1-ralf@mandelbit.com> <88b0bd75-fb61-4469-a98f-6e30b3a63824@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1660320"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:WxWFsnKugA0oeKRbCCbaP0oLp+g= sha256:iiR6c1ikDQMzAb4VHjPDxy4fmuski5z5CPM6zVs68JU= sha1:k7VHwkpC+nygOv4+91Vr1Q/xwYI= sha256:9BrfKdfnO9l08CuN2VrqfGd/pgMOngYFcGvCPNgB/x4= 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 23F131172CC; Tue, 1 Dec 2026 11:33:16 +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=[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-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 3gdoLWUUHxdb; Tue, 1 Dec 2026 11:33:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374848-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mandelbit.com X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 28F8911729A; Tue, 1 Dec 2026 11:33:10 +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 D00822627F; Tue, 1 Dec 2026 08:33:08 +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=1796113988; b=4MmA625kP8xiJ+4ys+h2K1Td1k4XONWFmILceQ/IAVk5BuLTCe2AIR+ZE/eA3ECWG5OU C2aQiHXWPgHeCqy72GIBHpE1SmLoia0ntqmj+6NjbjXazaiHR+BXoiEWrPMIjsa02lnvf XIBETVUFZoYX8sUXqW5DT6v7tDldtaWAkNXh08v6p4p0uQOM584JSfWCZ1+PIVaHEogIo AMOsgHaEzfs8mnVYMc+SM3z5fCzycVZGCED1PRc5Qh8j7eOl00241F/6Yzp7VtnfZXMmf lQrt5qt/SZKdYJ0XZBBHUFQ+tTmiwRvP/O/VGyAjePKsRpKOaFesyb1bvP3eTQGe57w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796113988; h=X-Original-To:Received:DMARC-Filter:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=vwIXhEiioa/YjjZL/uucYZgb42w3yF4CECY+7DxImbQ=; b=FiodRPZmc6a8M7MJzvcUBMznCV/6KuyRgYtmKE+vJZ8KSmu8IBGwv3krWiDM+fZQGrk5 d2qKEo4R5uOi+B53BNhZ+gpU5KLebR0RU9sVnF7jqAfR2adivue0U5MaMzJox+m//Sduc xsv6gMe4302UO5EfkiTWDMOLp4ZOZOu0dbhlJnxlCyXfan6fY6zzLoG7xWcdSvE7saWen sJ6144hFFQyc/b6T2lPIt8NAu4Y0T9k3q36+mCBUiCFhEDL0vXz6L/SlTmmiGX/JIRyZD Nk6ZhsZfg/7iHLknkDJjuA0gK3jgyM8Ek+Qtb+pKN0D+wu2dFWptJP5LX4JWyp6uXXA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; 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 4D2B2606A32C; Tue, 1 Dec 2026 08:33:08 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.62 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796113987; b=EvNZjXcHUZ5Hz3xPjXZt5k4k99GWUZX3R6OJHJkHDASlN0Fw6n2wxnIijuF/c/gARxmd 1kzIZt112cFeog2DGj4H79Y5qeFOpsmwyFKjRGSCinGDGAJvSj34nf+6X9piAIQCMPa8p guaLo6MC0wa7o+kzjt/AEOp5QxrEt+3nSWag3VpzGhtFurZ4+NAl+jSAwmKsGX9TdAfcd Ul0zJac26zuEtELieAaT6sZZbbdsEVStkrCPLAXw1NVLZdmxk8DWgPG/oVIbij3SmoWi7 metNIt8oAggLTrK93iNTH1czxPjv5SO8p0Uk+ZtqcQQrQguCDDzV3GNaFARiVsRJZtw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796113987; h=DMARC-Filter:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-Rspamd-Queue-Id; bh=vwIXhEiioa/YjjZL/uucYZgb42w3yF4CECY+7DxImbQ=; b=i//bQa7plZpoVdYRKjQXYD2sdsdzcUHKBs2TsOvaUY1JO0lgYymfjhnlj9CXqpcXbGKp VEc1jtp42vKZmF1jKI8XbscOWhX051nZjg0YlDKluf3ffM98qjDByQiAWadKeZpn1yVp2 boHNJonvccYUhESEl6dhdY1tPtqSM5JPe2Ic6vp2elRqV6iQUXn4BEn2eJnKzifKpy4/M JH1vhrGdMdISwk26FPZsPMlprcCfRe5xih7BQZl+OGcLBcR+ioIzF9I0Zx2QRLaUNcxTV fIiLOCjkz6aX3To4wSl88pW1+Ly4NYa8lnKVrw2kaEIMWa5iePWSxWw5PiAsBRYs3Fg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; arc=none smtp.remote-ip=195.10.208.62 X-Received: from mout-b-202.mailbox.org (mout-b-202.mailbox.org [195.10.208.62]) (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.subspace.kernel.org (Postfix) with ESMTPS id 3EA80606A31A for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 08:33:05 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3EA80606A31A X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com X-Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-202.mailbox.org (Postfix) with ESMTPS id 4jdvKR6FbdzKmKY; Tue, 01 Dec 2026 09:32:59 +0100 (CET) X-Authentication-Results: outgoing_mbo_mout; dkim=none; spf=temperror (outgoing_mbo_mout: error in processing during lookup of ralf@mandelbit.com: DNS error) smtp.mailfrom=ralf@mandelbit.com X-Cc: netdev@vger.kernel.org, idosch@nvidia.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, ja@ssi.bg, David Ahern <dahern@nvidia.com> X-Mailer: git-send-email 2.56.1 X-In-Reply-To: <88b0bd75-fb61-4469-a98f-6e30b3a63824@kernel.org> 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-Rspamd-Queue-Id: 4jdvKR6FbdzKmKY