* [PATCH 0/1] ipset patch for nf
@ 2024-06-17 9:18 Jozsef Kadlecsik
2024-06-17 9:18 ` [PATCH 1/1] netfilter: ipset: Fix suspicious rcu_dereference_protected() Jozsef Kadlecsik
0 siblings, 1 reply; 2+ messages in thread
From: Jozsef Kadlecsik @ 2024-06-17 9:18 UTC (permalink / raw)
To: netfilter-devel; +Cc: Pablo Neira Ayuso
Hi Pablo,
Please apply the next patch to the nf tree, which fixes a suspicious
rcu_dereference_protected() call.
- The patch fixing the race between namespace cleanup and gc in ipset left
out checking the pernet exit phase when calling rcu_dereference_protected(),
which thus resulted the suspicious RCU usage warning.
Best regards,
Jozsef
The following changes since commit 9bb49a1f0354a2ed2854af40d7051188b9b85837:
netfilter: ipset: Fix race between namespace cleanup and gc in the list:set type (2024-06-04 09:23:46 +0200)
are available in the Git repository at:
git://blackhole.kfki.hu/nf 0eb942092ce49
for you to fetch changes up to 0eb942092ce49307042e4603917f1e126ca50394:
netfilter: ipset: Fix suspicious rcu_dereference_protected() (2024-06-14 12:20:33 +0200)
----------------------------------------------------------------
Jozsef Kadlecsik (1):
netfilter: ipset: Fix suspicious rcu_dereference_protected()
net/netfilter/ipset/ip_set_core.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 1/1] netfilter: ipset: Fix suspicious rcu_dereference_protected()
2024-06-17 9:18 [PATCH 0/1] ipset patch for nf Jozsef Kadlecsik
@ 2024-06-17 9:18 ` Jozsef Kadlecsik
0 siblings, 0 replies; 2+ messages in thread
From: Jozsef Kadlecsik @ 2024-06-17 9:18 UTC (permalink / raw)
To: netfilter-devel; +Cc: Pablo Neira Ayuso
When destroying all sets, we are either in pernet exit phase or
are executing a "destroy all sets command" from userspace. The latter
was taken into account in ip_set_dereference() (nfnetlink mutex is held),
but the former was not. The patch adds the required check to
rcu_dereference_protected() in ip_set_dereference().
Reported-by: syzbot+b62c37cdd58103293a5a@syzkaller.appspotmail.com
Reported-by: syzbot+cfbe1da5fdfc39efc293@syzkaller.appspotmail.com
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202406141556.e0b6f17e-lkp@intel.com
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
---
net/netfilter/ipset/ip_set_core.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index c7ae4d9bf3d2..61431690cbd5 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -53,12 +53,13 @@ MODULE_DESCRIPTION("core IP set support");
MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_IPSET);
/* When the nfnl mutex or ip_set_ref_lock is held: */
-#define ip_set_dereference(p) \
- rcu_dereference_protected(p, \
+#define ip_set_dereference(inst) \
+ rcu_dereference_protected((inst)->ip_set_list, \
lockdep_nfnl_is_held(NFNL_SUBSYS_IPSET) || \
- lockdep_is_held(&ip_set_ref_lock))
+ lockdep_is_held(&ip_set_ref_lock) || \
+ (inst)->is_deleted)
#define ip_set(inst, id) \
- ip_set_dereference((inst)->ip_set_list)[id]
+ ip_set_dereference(inst)[id]
#define ip_set_ref_netlink(inst,id) \
rcu_dereference_raw((inst)->ip_set_list)[id]
#define ip_set_dereference_nfnl(p) \
@@ -1133,7 +1134,7 @@ static int ip_set_create(struct sk_buff *skb, const struct nfnl_info *info,
if (!list)
goto cleanup;
/* nfnl mutex is held, both lists are valid */
- tmp = ip_set_dereference(inst->ip_set_list);
+ tmp = ip_set_dereference(inst);
memcpy(list, tmp, sizeof(struct ip_set *) * inst->ip_set_max);
rcu_assign_pointer(inst->ip_set_list, list);
/* Make sure all current packets have passed through */
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-17 9:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-17 9:18 [PATCH 0/1] ipset patch for nf Jozsef Kadlecsik
2024-06-17 9:18 ` [PATCH 1/1] netfilter: ipset: Fix suspicious rcu_dereference_protected() Jozsef Kadlecsik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).