Skip to contentSkip to conversation

netfilter: ipset: Fix data race between add and list header

PATCH In review Jozsef Kadlecsik 4 participants 6 messages Mar 20

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover netfilter: ipset: Fix data race between add and list header

Hi Pablo,

Please consider applying the next patch:

* Fix data race between add and list header commands in all hash types by protecting the list header dumping part as well.

Best regards,
Jozsef

The following changes since commit 9ac76f3d0bb2940db3a9684d596b9c8f301ef315:

Merge tag 'wireless-next-2026-03-19' of https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next (2026-03-19 15:30:20 +0100)

are available in the Git repository at:

git://blackhole.kfki.hu/nf-next 1962de9a3ef9136598a53

for you to fetch changes up to 1962de9a3ef9136598a538898fe750094d3f9ab6:

netfilter: ipset: Fix data race between add and list header in all hash types (2026-03-20 12:33:37 +0100)

----------------------------------------------------------------
Jozsef Kadlecsik (1):
netfilter: ipset: Fix data race between add and list header in all hash types

 net/netfilter/ipset/ip_set_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#1 lore raw

PATCH 1/1 netfilter: ipset: Fix data race between add and list header in all hash types

The "ipset list -terse" command is actually a dump operation which may run parallel with "ipset add" commands, which can trigger an internal resizing of the hash type of sets just being dumped. However, dumping just the header part of the set was not protected against underlying resizing. Fix it by protecting the header dumping part as well.

---
 net/netfilter/ipset/ip_set_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/ipset/ip_set_core.c +2 -2
index a2fe711cb5e3..2cc04da95afd 100644
@@ -1648,13 +1648,13 @@ ip_set_dump_do(struct sk_buff *skb, struct netlink_callback *cb)
 			if (cb->args[IPSET_CB_PROTO] > IPSET_PROTOCOL_MIN &&
 			    nla_put_net16(skb, IPSET_ATTR_INDEX, htons(index)))
 				goto nla_put_failure;
+			if (set->variant->uref)
+				set->variant->uref(set, cb, true);
 			ret = set->variant->head(set, skb);
 			if (ret < 0)
 				goto release_refcount;
 			if (dump_flags & IPSET_FLAG_LIST_HEADER)
 				goto next_set;
-			if (set->variant->uref)
-				set->variant->uref(set, cb, true);
 			fallthrough;
 		default:
 			ret = set->variant->list(set, skb, cb);
Signature · 1 line
2.39.5
maintainer
#2 lore raw
In reply to Jozsef Kadlecsik
Quoted 6 lines · Jozsef Kadlecsik

Hi Pablo,

Please consider applying the next patch:

* Fix data race between add and list header commands in all hash types by protecting the list header dumping part as well.

Thanks Jozsef for the quick fix.
Just to be sure, is this nf-next or nf material?

And, what do you make of:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
and
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

?

Thanks!

#3 lore raw
Quoted 10 lines · Florian Westphal
Quoted 6 lines · Jozsef Kadlecsik

Hi Pablo,

Please consider applying the next patch:

* Fix data race between add and list header commands in all hash types by protecting the list header dumping part as well.

Thanks Jozsef for the quick fix.
Just to be sure, is this nf-next or nf material?

I think this is nf material, to deal with the KCSAN report from syzbot.

Quoted 9 lines

And, what do you make of:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
and
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

?

Thanks!

#4 lore raw
Quoted 5 lines · Pablo Neira Ayuso
Quoted 4 lines · Florian Westphal
Quoted 3 lines · Jozsef Kadlecsik

Please consider applying the next patch:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

* Fix data race between add and list header commands in all hash types by protecting the list header dumping part as well.

Thanks Jozsef for the quick fix.
Just to be sure, is this nf-next or nf material?

I think this is nf material, to deal with the KCSAN report from syzbot.

The patch can be applied cleanly on top of nf too, so yes, better nf and not nf-next.

Best regards,
Jozsef

Signature · 3 lines
E-mail : [email protected], [email protected], [email protected]
Address: Wigner Research Centre for Physics
         H-1525 Budapest 114, POB. 49, Hungary
author Acked-by
#5 lore raw
In reply to Florian Westphal
Quoted 1 line · Florian Westphal

Just to be sure, is this nf-next or nf material?

I was unsure about it, because of the missing reproducer I could not verify the fix.

Quoted 5 lines

And, what do you make of:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
and
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

For both patches:

Thanks for reminding me about the pending patches!

Best regards,
Jozsef

Signature · 3 lines
E-mail : [email protected], [email protected], [email protected]
Address: Wigner Research Centre for Physics
         H-1525 Budapest 114, POB. 49, Hungary