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=lQgn6/XJMzrISSBWr0pqftX72Wvxhy+fkFugGTKqFNUQT109NdOdbprYauKun9VcZvD0 WUMuh+cYuWUsnx9nF3wFBHIVYKI+unlTZkGi5xnL9nHxdxqN5gETA+w72Qu4U2LD6KMK2 qhD4GrAPjueV0pBT+Ke4YbsSmaJCwWf3Fwtb3vY96mbgfrmcMioV32uU+zVnwjUleyrwT 9QOlE9VdT7OYLtoZ21uk6YVThLPsIheuJQ548FlPEQcaECAlr6yyrq5L7BGYt1rEZgYs/ 79r27asHZDibLuBUr1q6fomIqayLHMk8vN4+nNGR7g1GJg4dZFyVoA0gjvZ+YgGU0ew== 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=B8GVuDrSbXdjPs9ADyXO4RU/TYCpQPx0Apz6FvjzJsU=; b=XBVPVxXx6hia9mkHTpbac8RSw4QhyC65OeEfNo5gaWmhyAGomqjRxrDo2drdIlJSWTR3 JiCISYLSMQY0b/j8rh4nGuzBYz2RX2HY2y5STopvjYPmkOlaIWM2ul99kJT8VghRdmOz+ FAzghn13vCDjy1/yNG/YZiaouVDu8bYN/nWy+a3FoduOBdmsng3HL1scfc1TrzfDEKK5f 7UlaaYjNhCngZMl6WEJ0wMqYNxe+rlTdOWsS/rr3py/XAG9ZwEUOjkAVCJcsdqqWAsdbc q+hrieB2MBRhT73kyf3+NdjnIceGPKwG1tA1XYPhIIqWzqFDHdcm2tEN1iobOnTayiw== 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=ZgYm0W+H; 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 D65F3606A334 for ; Sat, 5 Dec 2026 19:20:53 +0000 (UTC) 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=ZgYm0W+H Received: by smtp.kernel.org (Postfix) with ESMTPSA id 083581F00936; Sat, 5 Dec 2026 19:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796498453; bh=B8GVuDrSbXdjPs9ADyXO4RU/TYCpQPx0Apz6FvjzJsU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ZgYm0W+HbEeKVPfukFl/uzyJrVk3+JV2Igi7ozjmou0oyaGCCTsLA5hH83Fzr6W5U 3ehWoA8oVeKJnPf4sDJBH/jNiwyanze2BWkC++Oiokl/d29SuLxPNY6qmj6sMrIi0J 4mssT4raZzwpK6csnGZRSPES1+6L0J7+5ZAkVtKZTEN7vamPH1mv3D5rAIW4PnxZ6m 4KHiGWjj7rJPG5FLnXtR1bucuwCRNdclgb7d7uykazuO/Hus5QtpTHZH9bAMaP7DNH kHovLluWn6DYxaPLngtldCanrSFZDrY5n+nIIUtO0em4knouMX/DNHc1+u18JDKLM7 6iWBVHAUoRr+w== Subject: Re: [PATCH net-next v3 03/13] ipv6: don't insert a PMTU exception whose MTU could not be stored 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:52 +0000 Message-ID: <179649845261.3148.1001468148318937531@kernel.org> In-Reply-To: <20261201174021.7211-4-dsahern@kernel.org> References: <20261201174021.7211-4-dsahern@kernel.org> X-sashiko-severity: Medium 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 1 potential issue(s) to consider. Critical: 0 · 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). - [Medium] The compare-and-exchange protocol in rt6_lower_mtu() only protects against other PMTU handlers. -- ipv6: don't insert a PMTU exception whose MTU could not be stored This patch makes rt6_do_update_pmtu() allocate writable metrics up front and return an error if that fails. When it fails, a new exception is not inserted and an existing one does not get its stamp refreshed. It also adds rt6_lower_mtu(), which lowers RTAX_MTU with try_cmpxchg() so that a smaller value stored at the same time by another PMTU handler is kept. > diff --git a/net/ipv6/route.c b/net/ipv6/route.c > index 31ebcf6652166..06afb9d5dc2b1 100644 > --- a/net/ipv6/route.c > +++ b/net/ipv6/route.c > @@ -1546,6 +1546,34 @@ static struct net *rt6_exception_net(const struct rt6_info *rt) > return container_of(rt->dst.ops, struct net, ipv6.ip6_dst_ops); > } > > +/* Lower the MTU in the metrics of @rt to @mtu. > + * > + * A dst shares the read-only metrics of its route until it needs its own. > + * Allocating them can fail, and dst_metric_set() does not say: the PMTU would > + * be lost. > + * > + * Only ever lower it, and with a compare and exchange: PMTU handlers update a > + * dst in place without a lock, and each decides to lower the MTU from a value > + * it read earlier, so storing unconditionally could overwrite a smaller value > + * that another handler stored in between. > + */ > +static int rt6_lower_mtu(struct rt6_info *rt, u32 mtu) > +{ > + u32 *metrics = dst_metrics_write_ptr(&rt->dst); > + u32 old; > + > + if (!metrics) > + return -ENOMEM; > + > + old = READ_ONCE(metrics[RTAX_MTU - 1]); > + do { > + if (old && old <= mtu) > + break; > + } while (!try_cmpxchg(&metrics[RTAX_MTU - 1], &old, mtu)); [Severity: Medium] Does this fully deliver the "only ever goes down and a smaller value stored meanwhile is kept" guarantee from the commit message? Another writer of the same RTAX_MTU word on exception dsts was left unchanged. On NETDEV_CHANGEMTU, fib6_nh_mtu_change() takes only rt6_exception_lock and calls rt6_exceptions_update_pmtu(). That function first reads the current MTU, then does a plain store: net/ipv6/route.c:rt6_mtu_change_route_allowed() { u32 dmtu = dst6_mtu(&rt->dst); ... } net/ipv6/route.c:rt6_exceptions_update_pmtu() { ... if (dst_metric_raw(&entry->dst, RTAX_MTU) && rt6_mtu_change_route_allowed(idev, entry, mtu)) dst_metric_set(&entry->dst, RTAX_MTU, mtu); ... } dst_metric_set() ends up doing an unconditional "p[metric-1] = val;". The in-place path __ip6_rt_update_pmtu()->rt6_do_update_pmtu()-> rt6_lower_mtu() never takes rt6_exception_lock. So the two writers do not share a lock. Here is one example. An exception has PMTU 1500 and the device MTU is lowered to 1450: CPU1 (NETDEV_CHANGEMTU) rt6_exceptions_update_pmtu() rt6_mtu_change_route_allowed() dmtu = 1500, decides to store 1450 CPU0 (ICMPv6 Packet Too Big, 1280, same RTF_CACHE dst) __ip6_rt_update_pmtu() rt6_do_update_pmtu() rt6_lower_mtu() try_cmpxchg() 1500 -> 1280 rt6_update_exception_stamp_rt() CPU1 dst_metric_set(&entry->dst, RTAX_MTU, 1450) The 1280 just learned is replaced by 1450. Packets then exceed the path MTU until another Packet Too Big arrives. The same can happen when the device MTU is raised and dmtu == idev->cnf.mtu6. That looks like the overwrite the commit message describes, where "a handler that decided on 1400 overwrite a 1280 that another one stored in between". It also means a plain store races with READ_ONCE() and try_cmpxchg() on the same u32, which KCSAN may report. This still holds at the end of the series. The later commit "ipv6: validate dsts against the netns route generation" says the device MTU change path "is not covered by that". Its rt6_exception_merge() comment repeats the "neither overwrites what the other stored" guarantee, which this path does not honour. Could rt6_exceptions_update_pmtu() store conditionally instead? For example, it could try_cmpxchg() from the raw value it read, so the store only lands if nothing changed. Another option is to have both writers take the same lock. > + > + return 0; > +} > + [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201174021.7211-1-dsahern%40kernel.org