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
Subject: Re: [PATCH net-next v3 03/13] ipv6: don't insert a PMTU exception whose MTU could not be stored
Date: Sat, 05 Dec 2026 19:20:52 +0000 [thread overview]
Message-ID: <179649845261.3148.1001468148318937531@kernel.org> (raw)
In-Reply-To: <20261201174021.7211-4-dsahern@kernel.org>
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
next prev parent reply other threads:[~2026-12-05 19:20 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 17:40 [PATCH net-next v3 00/13] ipv6: validate cached dsts against the netns route generation David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 01/13] ipv6: allocate the exception entry before removing the one it replaces David Ahern
2026-12-02 16:02 ` Ido Schimmel
2026-12-01 17:40 ` [PATCH net-next v3 02/13] ipv6: keep a superseded pcpu dst working until its holders notice David Ahern
2026-12-02 16:19 ` Ido Schimmel
2026-12-05 19:20 ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 03/13] ipv6: don't insert a PMTU exception whose MTU could not be stored David Ahern
2026-12-05 19:20 ` netdev-bot+sashiko [this message]
2026-12-01 17:40 ` [PATCH net-next v3 04/13] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-12-05 19:20 ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 05/13] ipv6: tell route dumps about exception inserts with a table sequence David Ahern
2026-12-05 19:20 ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 06/13] ipv6: validate dsts against the netns route generation David Ahern
2026-12-05 19:20 ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 07/13] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
2026-12-05 19:20 ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 08/13] nexthop: factor out nh_has_f6i() David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 09/13] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-12-05 19:20 ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 10/13] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern
2026-12-05 19:21 ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 11/13] selftests: net: pmtu: check that a deleted cached exception stays deleted David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 12/13] selftests: net: fib_tests: Add stale pcpu test David Ahern
2026-12-05 19:21 ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 13/13] selftests: net: ipvs: check a PMTU learned after the DR route was cached David Ahern
2026-12-05 19:21 ` netdev-bot+sashiko
2026-12-01 17:43 ` [PATCH net-next v3 00/13] ipv6: validate cached dsts against the netns route generation netdev-bot+sinfo
2026-12-02 9:45 ` Ralf Lici
2026-12-03 15:34 ` Ido Schimmel
2026-12-03 15:44 ` David Ahern
2026-12-03 16:55 ` Ralf Lici
2026-12-03 17:16 ` Ido Schimmel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179649845261.3148.1001468148318937531@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=dahern@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=ja@ssi.bg \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=noreply@anthropic.com \
--cc=pabeni@redhat.com \
--cc=ralf@mandelbit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.