From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
David Ahern <dsahern@kernel.org>
Cc: Ido Schimmel <idosch@nvidia.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>, Thomas Graf <tgraf@suug.ch>,
Cen Zhang <cenzhang@linux.microsoft.com>,
netdev@vger.kernel.org
Subject: [PATCH net] ipv6: skip walkers of other tables when a route leaves the tree
Date: Wed, 25 Nov 2026 23:52:58 +0900 [thread overview]
Message-ID: <179561512100.3216623.16734853197511150282@gmail.com> (raw)
fib6_walkers_replace_leaf() runs under the tb6_lock of the route's
table but checks every walker of the netns, including walkers of other
tables, which run under their own table's lock. Such a walker can be
anywhere in its walk: fib6_walk_continue() sets w->state to FWS_C
before it sets w->leaf, and the walker of fib6_clean_tree() starts with
an uninitialized w->leaf on the stack. A route delete in one table
while a link change cleans another one compares that value:
BUG: KMSAN: uninit-value in fib6_del (net/ipv6/ip6_fib.c:103)
fib6_del (net/ipv6/ip6_fib.c:103 ip6_fib.c:123 ip6_fib.c:2056)
__ip6_del_rt_siblings (net/ipv6/route.c:4086)
ip6_route_del (net/ipv6/route.c:4235)
inet6_rtm_delroute (net/ipv6/route.c:5686)
rtnetlink_rcv_msg (net/core/rtnetlink.c:7169)
Local variable c.i created at:
__fib6_clean_all (net/ipv6/ip6_fib.c:2315 net/ipv6/ip6_fib.c:2344)
fib6_clean_all (net/ipv6/ip6_fib.c:2355)
A walker of another table never rests on a route of this table, so
skip it.
Fixes: c71099acce93 ("[IPV6]: Multiple Routing Tables")
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
The issue was found by an LLM-guided test generator that we are
developing as a research prototype. A reproducer, which runs as any
user: one thread toggles lo, so that fib6_clean_all() walks every
table, while the main thread adds and deletes a route in the main
table.
#define _GNU_SOURCE
#include <arpa/inet.h>
#include <net/if.h>
#include <net/route.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <unistd.h>
static int s;
/* link changes walk every FIB table with fib6_clean_all() */
static void *toggle(void *arg)
{
struct ifreq lo = { .ifr_name = "lo" };
for (;;) {
lo.ifr_flags = 0;
ioctl(s, SIOCSIFFLAGS, &lo);
lo.ifr_flags = IFF_UP;
ioctl(s, SIOCSIFFLAGS, &lo);
}
return arg;
}
/* route deletes scan the walkers of all tables */
int main(void)
{
struct in6_rtmsg rt = {
.rtmsg_dst_len = 64,
.rtmsg_metric = 1,
.rtmsg_flags = RTF_UP,
.rtmsg_ifindex = 1, /* lo */
};
pthread_t t;
if (unshare(CLONE_NEWUSER | CLONE_NEWNET))
return perror("unshare"), 1;
s = socket(AF_INET6, SOCK_DGRAM, 0);
inet_pton(AF_INET6, "2001:db8:1::", &rt.rtmsg_dst);
pthread_create(&t, NULL, toggle, NULL);
for (int i = 0; i < 2000000; i++) {
ioctl(s, SIOCADDRT, &rt);
ioctl(s, SIOCDELRT, &rt);
}
return 0;
}
Without the patch, KMSAN reports the uninit-value above; with it,
the reproducer runs to the end without a report.
The patch was written with LLM assistance; we reviewed and tested it.
net/ipv6/ip6_fib.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index e1d49897d6ab..0d0748e31f57 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -100,6 +100,9 @@ static void fib6_walkers_replace_leaf(struct net *net, struct fib6_info *old,
read_lock(&net->ipv6.fib6_walker_lock);
FOR_WALKERS(net, w) {
+ /* Only walkers of this table are serialized by its tb6_lock */
+ if (w->root != &old->fib6_table->tb6_root)
+ continue;
if (w->state == FWS_C && w->leaf == old) {
pr_debug("walker %p adjusted by unlink of %p\n", w, old);
w->leaf = new;
--
2.43.0
reply other threads:[~2026-11-25 14:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=179561512100.3216623.16734853197511150282@gmail.com \
--to=kyuwoncho18@gmail.com \
--cc=cenzhang@linux.microsoft.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tgraf@suug.ch \
--cc=willemb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox