[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <697a0bd6.a70a0220.9914.0000.GAE@google.com>
Date: Wed, 28 Jan 2026 05:15:02 -0800
From: syzbot <syzbot+d417922a3e7935517ef6@...kaller.appspotmail.com>
To: linux-kernel@...r.kernel.org, syzkaller-bugs@...glegroups.com
Subject: Forwarded: [PATCH] netfilter: nf_tables: fix use-after-free in
nft_set_elem lookup
For archival purposes, forwarding an incoming command email to
linux-kernel@...r.kernel.org, syzkaller-bugs@...glegroups.com.
***
Subject: [PATCH] netfilter: nf_tables: fix use-after-free in nft_set_elem lookup
Author: kartikey406@...il.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main
Add RCU read-side critical section in nft_get_set_elem() to protect
against concurrent element deletion by garbage collection.
The lookup path in nft_rbtree_get() dereferences set elements through
interval->from and interval->to pointers via nft_array_get_cmp().
These elements can be freed by nft_trans_gc_trans_free() running in
an RCU callback context while the lookup is in progress, leading to
a use-after-free.
The crash occurs in nft_array_get_cmp() when it calls nft_set_ext_key()
on a freed element:
BUG: KASAN: slab-use-after-free in nft_array_get_cmp+0x1f6/0x2a0
Protect the element lookup with rcu_read_lock()/rcu_read_unlock() to
ensure the RCU grace period extends until after we're done accessing
the element data. This prevents the GC callback from freeing elements
while they're being accessed.
Reported-by: syzbot+d417922a3e7935517ef6@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d417922a3e7935517ef6
Signed-off-by: Deepanshu Kartikey <kartikey406@...il.com>
---
net/netfilter/nf_tables_api.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index be4924aeaf0e..57affe22e0bd 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -6540,7 +6540,10 @@ static int nft_get_set_elem(struct nft_ctx *ctx, const struct nft_set *set,
return err;
}
+ rcu_read_lock();
err = nft_setelem_get(ctx, set, &elem, flags);
+ rcu_read_unlock();
+
if (err < 0)
return err;
--
2.43.0
Powered by blists - more mailing lists