Re: [PATCH net-next v5 2/4] ipv6: take fib6_sernum from a sequence shared by all netns

From: netdev-bot+sashiko

Date: Sun Nov 22 2026 - 19:25:56 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

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] Once the shared fib6_sernum_seq has wrapped, a bump in
fib6_new_sernum() (net/ipv6/ip6_fib.c) can set a netns' fib6_sernum to…
- [Low] The commit message has no Fixes: tag and does not mention stable.

--

ipv6: take fib6_sernum from a sequence shared by all netns

This patch makes fib6_new_sernum() draw every fib6_sernum bump from one
sequence shared by all netns. The sequence hands out values from 2 to
INT_MAX and then wraps to 2. The goal is that a per-cpu nexthop route
cached against one netns no longer matches the sernum of another netns
after its device moves. rt6_is_valid() also now rejects sernum 1, the
value every netns starts with.

> diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
> index e1d49897d6ab0..71490edb01e99 100644
> --- a/net/ipv6/ip6_fib.c
> +++ b/net/ipv6/ip6_fib.c
> @@ -123,12 +123,38 @@ static void fib6_walkers_skip_rt(struct net *net, struct fib6_info *rt)

[ ... ]

> +static atomic_t fib6_sernum_seq = ATOMIC_INIT(1);
> +
> +static int fib6_sernum_draw(void)
> +{
> + int new, old = atomic_read(&fib6_sernum_seq);
> +
> + do {
> + new = old < INT_MAX ? old + 1 : 2;
> + } while (!atomic_try_cmpxchg(&fib6_sernum_seq, &old, new));
> +
> + return new;
> +}

[ ... ]

> static int fib6_new_sernum(struct net *net)
> {
> int new, old = atomic_read(&net->ipv6.fib6_sernum);
>
> do {
> - new = old < INT_MAX ? old + 1 : 1;
> + new = fib6_sernum_draw();
> } while (!atomic_try_cmpxchg(&net->ipv6.fib6_sernum, &old, new));
>
> return new;

[Severity: Medium]
Once fib6_sernum_seq has wrapped, can fib6_new_sernum() publish the value
the netns already holds?

Suppose a netns publishes V and then makes no more bumps. Meanwhile other
netns make about 2^31 - 2 bumps through route add/del, PMTU exceptions or
flushes. The next draw for this netns can then return V again:

fib6_new_sernum()
old = atomic_read(&net->ipv6.fib6_sernum); /* V */
new = fib6_sernum_draw(); /* V again after the wrap */
atomic_try_cmpxchg(&net->ipv6.fib6_sernum, &old, new); /* succeeds */

The callers then write V onto nodes that already hold V:

- fib6_add() via __fib6_update_sernum_upto_root()
- fib6_update_sernum_upto_root()
- fib6_update_sernum() from rt6_insert_exception()
- fib6_flush_trees() via __fib6_clean_all()

So the bump has no effect.

Would cookie-validated dsts then still pass fib6_check() and rt6_check(),
and would nexthop per-cpu dsts with sernum V still pass rt6_is_valid()?
If so, sockets would keep stale routes after a new more-specific route,
an exception insert or a flush, until the next real bump.

The old formula (old < INT_MAX ? old + 1 : 1) could never return a value
equal to old. Would drawing again while new == old be enough to close
this?

> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 4a4c5ace63c54..6731665fbb16d 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1466,7 +1466,11 @@ static struct rt6_info *ip6_rt_pcpu_alloc(const struct fib6_result *res)
>
> static bool rt6_is_valid(const struct rt6_info *rt6)
> {
> - return rt6->sernum == rt_genid_ipv6(dev_net(rt6->dst.dev));
> + /* Reject the initial sernum, which every netns shares and which a
> + * route can record before its insertion bumps the sernum.
> + */
> + return rt6->sernum != 1 &&
> + rt6->sernum == rt_genid_ipv6(dev_net(rt6->dst.dev));
> }

[Severity: Low]
This isn't a bug, but should the commit message carry a Fixes: tag, and
possibly a Cc: stable line?

The comparison in rt6_is_valid() and this line in ip6_rt_pcpu_alloc()
both come from commit 8f34e53b60b3 ("ipv6: Use global sernum for dst
validation with nexthop objects"):

pcpu_rt->sernum = rt_genid_ipv6(dev_net(dev));

That line stores the sernum of the creating netns on per-cpu nexthop
routes.

Without Fixes: 8f34e53b60b3, stable backporters and automated stable
selection cannot tell which kernels need this fix.

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121-bug-net-netns-move-rcu-barrier-v5-0-100a3b5d9090%40linux.dev