From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.62 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== 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== 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 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 ; Tue, 1 Dec 2026 08:33:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3EA80606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com 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) 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 From: Ralf Lici To: David Ahern 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 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 Message-ID: <20261201083252.37868-1-ralf@mandelbit.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <88b0bd75-fb61-4469-a98f-6e30b3a63824@kernel.org> References: <52846eb18319fc2841ffa6dbb32abcc898eca8df.1795642432.git.dahern@nvidia.com> <20261127110319.354669-1-ralf@mandelbit.com> <88b0bd75-fb61-4469-a98f-6e30b3a63824@kernel.org> 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 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4jdvKR6FbdzKmKY On Mon, 30 Nov 2026 12:31:58 -0700, David Ahern wrote: > On 11/27/26 4:03 AM, Ralf Lici wrote: > > On Wed, 25 Nov 2026 18:33:32 -0700, David Ahern 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