Skip to content

Commit 27c5a09

Browse files
Jozsef Kadlecsikummakynes
authored andcommitted
netfilter: ipset: Missing gc cancellations fixed
The patch fdb8e12cc2cc ("netfilter: ipset: fix performance regression in swap operation") missed to add the calls to gc cancellations at the error path of create operations and at module unload. Also, because the half of the destroy operations now executed by a function registered by call_rcu(), neither NFNL_SUBSYS_IPSET mutex or rcu read lock is held and therefore the checking of them results false warnings. Fixes: 97f7cf1 ("netfilter: ipset: fix performance regression in swap operation") Reported-by: [email protected] Reported-by: Brad Spengler <[email protected]> Reported-by: Стас Ничипорович <[email protected]> Tested-by: Brad Spengler <[email protected]> Tested-by: Стас Ничипорович <[email protected]> Signed-off-by: Jozsef Kadlecsik <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent ab0beaf commit 27c5a09

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

net/netfilter/ipset/ip_set_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,7 @@ static int ip_set_create(struct sk_buff *skb, const struct nfnl_info *info,
11541154
return ret;
11551155

11561156
cleanup:
1157+
set->variant->cancel_gc(set);
11571158
set->variant->destroy(set);
11581159
put_out:
11591160
module_put(set->type->me);
@@ -2378,6 +2379,7 @@ ip_set_net_exit(struct net *net)
23782379
set = ip_set(inst, i);
23792380
if (set) {
23802381
ip_set(inst, i) = NULL;
2382+
set->variant->cancel_gc(set);
23812383
ip_set_destroy_set(set);
23822384
}
23832385
}

net/netfilter/ipset/ip_set_hash_gen.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ mtype_ahash_destroy(struct ip_set *set, struct htable *t, bool ext_destroy)
432432
u32 i;
433433

434434
for (i = 0; i < jhash_size(t->htable_bits); i++) {
435-
n = __ipset_dereference(hbucket(t, i));
435+
n = (__force struct hbucket *)hbucket(t, i);
436436
if (!n)
437437
continue;
438438
if (set->extensions & IPSET_EXT_DESTROY && ext_destroy)
@@ -452,7 +452,7 @@ mtype_destroy(struct ip_set *set)
452452
struct htype *h = set->data;
453453
struct list_head *l, *lt;
454454

455-
mtype_ahash_destroy(set, ipset_dereference_nfnl(h->table), true);
455+
mtype_ahash_destroy(set, (__force struct htable *)h->table, true);
456456
list_for_each_safe(l, lt, &h->ad) {
457457
list_del(l);
458458
kfree(l);

0 commit comments

Comments
 (0)