netfilter: ipset: Add list flush to cancel_gc
authorAlexander Maltsev <keltar.gw@gmail.com>
Wed, 17 Apr 2024 13:51:41 +0000 (18:51 +0500)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 20 May 2024 18:38:42 +0000 (20:38 +0200)
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.

Fixes: 97f7cf1cd80e ("netfilter: ipset: fix performance regression in swap operation")
Signed-off-by: Alexander Maltsev <keltar.gw@gmail.com>
Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/ipset/ip_set_list_set.c

index 6c3f28bc59b3259f0033cd4adc0ba5711db08c26..54e2a1dd7f5f5163fef436dc6ed000ce25e837b7 100644 (file)
@@ -549,6 +549,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 = {