Skip to content

Commit 1a9da59

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: ipt_CLUSTERIP: put config instead of freeing it
Once struct is added to per-netns list it becomes visible to other cpus, so we cannot use kfree(). Also delay setting entries refcount to 1 until after everything is initialised so that when we call clusterip_config_put() in this spot entries is still zero. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 8ae5682 commit 1a9da59

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/ipv4/netfilter/ipt_CLUSTERIP.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ clusterip_config_init(struct net *net, const struct ipt_clusterip_tgt_info *i,
232232
c->hash_mode = i->hash_mode;
233233
c->hash_initval = i->hash_initval;
234234
refcount_set(&c->refcount, 1);
235-
refcount_set(&c->entries, 1);
236235

237236
spin_lock_bh(&cn->lock);
238237
if (__clusterip_config_find(net, ip)) {
@@ -263,8 +262,10 @@ clusterip_config_init(struct net *net, const struct ipt_clusterip_tgt_info *i,
263262

264263
c->notifier.notifier_call = clusterip_netdev_event;
265264
err = register_netdevice_notifier(&c->notifier);
266-
if (!err)
265+
if (!err) {
266+
refcount_set(&c->entries, 1);
267267
return c;
268+
}
268269

269270
#ifdef CONFIG_PROC_FS
270271
proc_remove(c->pde);
@@ -273,7 +274,7 @@ clusterip_config_init(struct net *net, const struct ipt_clusterip_tgt_info *i,
273274
spin_lock_bh(&cn->lock);
274275
list_del_rcu(&c->list);
275276
spin_unlock_bh(&cn->lock);
276-
kfree(c);
277+
clusterip_config_put(c);
277278

278279
return ERR_PTR(err);
279280
}

0 commit comments

Comments
 (0)