Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Kyuwon Cho
Wed, 25 Nov 2026 14:52
[PATCH net] ipv6: skip walkers of other tables when a route leaves the tree
Author: Kyuwon Cho
Date: Wed, 25 Nov 2026 14:52
Date: Wed, 25 Nov 2026 14:52
105 lines
13929 bytes
13929 bytes
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
Re: [PATCH net] ipv6: skip walkers of other tables when a route leaves the tree
Author: patchwork-bot+netdevbpf
Date: Wed, 02 Dec 2026 02:40
Date: Wed, 02 Dec 2026 02:40
25 lines
8902 bytes
8902 bytes
Hello:
This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:
On Wed, 25 Nov 2026 23:52:58 +0900 you wrote:
> 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:
>
> [...]
Here is the summary with links:
- [net] ipv6: skip walkers of other tables when a route leaves the tree
https://git.kernel.org/netdev/net/c/5e16fbd6c96b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads