public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+d417922a3e7935517ef6@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] netfilter: nf_tables: add missing RCU read lock in nf_tables_getsetelem
Date: Wed, 28 Jan 2026 06:54:20 -0800	[thread overview]
Message-ID: <697a231c.a70a0220.8545c.0002.GAE@google.com> (raw)
In-Reply-To: <6979fc44.050a0220.c9109.003b.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] netfilter: nf_tables: add missing RCU read lock in nf_tables_getsetelem
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main

Add RCU read-side critical section in nf_tables_getsetelem() to protect
against concurrent element deletion by garbage collection.

The function nf_tables_getsetelem() calls nft_get_set_elem() which
eventually dereferences set elements through the rbtree lookup path.
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 function nf_tables_getsetelem_reset() already has proper RCU
protection around the same code path. This patch adds the missing RCU
read lock to nf_tables_getsetelem() to match.

Reported-by: syzbot+d417922a3e7935517ef6@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d417922a3e7935517ef6
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 net/netfilter/nf_tables_api.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index be4924aeaf0e..00af242b1e62 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -6628,6 +6628,7 @@ static int nf_tables_getsetelem(struct sk_buff *skb,
 	if (err)
 		return err;
 
+	rcu_read_lock();
 	nla_for_each_nested(attr, nla[NFTA_SET_ELEM_LIST_ELEMENTS], rem) {
 		err = nft_get_set_elem(&dump_ctx.ctx, dump_ctx.set, attr, false);
 		if (err < 0) {
@@ -6635,6 +6636,7 @@ static int nf_tables_getsetelem(struct sk_buff *skb,
 			break;
 		}
 	}
+	rcu_read_unlock();
 
 	return err;
 }
-- 
2.43.0


      parent reply	other threads:[~2026-01-28 14:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 12:08 [syzbot] [netfilter?] KASAN: slab-use-after-free Read in nft_array_get_cmp syzbot
2026-01-28 13:15 ` Forwarded: [PATCH] netfilter: nf_tables: fix use-after-free in nft_set_elem lookup syzbot
2026-01-28 13:40 ` [syzbot] [netfilter?] KASAN: slab-use-after-free Read in nft_array_get_cmp Florian Westphal
2026-01-28 16:35   ` Florian Westphal
2026-01-28 14:54 ` syzbot [this message]

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=697a231c.a70a0220.8545c.0002.GAE@google.com \
    --to=syzbot+d417922a3e7935517ef6@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.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