Skip to contentSkip to conversation

netfilter: ipset: Add list flush to cancel_gc

PATCH In review Alexander Maltsev 3 participants 3 messages Apr 17, 2024 – May 20, 2024 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: ipset: Add list flush to cancel_gc

Flushing list in cancel_gc drops references to other lists right away, without waiting for RCU to destroy list. Fixes race when referenced ipsets can't be destroyed while referring list is scheduled for destroy.

---
 kernel/net/netfilter/ipset/ip_set_list_set.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/net/netfilter/ipset/ip_set_list_set.c +3 -0
index cc2e5b9..0d15f4f 100644
@@ -552,6 +552,9 @@ list_set_cancel_gc(struct ip_set *set)
 
 	if (SET_WITH_TIMEOUT(set))
 		timer_shutdown_sync(&map->gc);
+
+	/* Flush list to drop references to other ipsets */
+	list_set_flush(set);
 }
 
 static const struct ip_set_type_variant set_variant = {
Signature · 1 line
2.44.0
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Alexander Maltsev

Flushing list in cancel_gc drops references to other lists right away, without waiting for RCU to destroy list. Fixes race when referenced ipsets can't be destroyed while referring list is scheduled for destroy.

---
 kernel/net/netfilter/ipset/ip_set_list_set.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/net/netfilter/ipset/ip_set_list_set.c +0 -0
index cc2e5b9..0d15f4f 100644

kernel/net/netfilter/ipset/ip_set_list_set.c list_set_cancel_gc(struct ip_set *set) · line 560

Quoted 9 lines
kernel/net/netfilter/ipset/ip_set_list_set.c +3 -0
@@ -552,6 +552,9 @@ list_set_cancel_gc(struct ip_set *set)
 
 	if (SET_WITH_TIMEOUT(set))
 		timer_shutdown_sync(&map->gc);
+
+	/* Flush list to drop references to other ipsets */
+	list_set_flush(set);
 }
 
 static const struct ip_set_type_variant set_variant = {

Looks good, Pablo please apply to the nf-next tree. Thanks!

Best regards,
Jozsef

Signature · 4 lines
E-mail  : [email protected], [email protected]
PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics
          H-1525 Budapest 114, POB. 49, Hungary
#2 lore raw
In reply to Alexander Maltsev
Quoted 3 lines · Alexander Maltsev

Flushing list in cancel_gc drops references to other lists right away, without waiting for RCU to destroy list. Fixes race when referenced ipsets can't be destroyed while referring list is scheduled for destroy.

For the record, I have applied this patch to nf.git with this tag:

Fixes 97f7cf1cd80e ("netfilter: ipset: fix performance regression in swap operation")

I overlook this patch, apologies for the delay.