]> git.karo-electronics.de Git - karo-tx-linux.git/commit
netfilter: ipt_CLUSTERIP: check duplicate config when initializing
authorXin Long <lucien.xin@gmail.com>
Tue, 20 Dec 2016 11:14:34 +0000 (19:14 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 23 Dec 2016 14:20:01 +0000 (15:20 +0100)
commit6c5d5cfbe3c59429e6d6f66477a7609aacf69751
tree19435ae7ae7d2fe3d802de8672a535597eca32ab
parent053d20f5712529016eae10356e0dea9b360325bd
netfilter: ipt_CLUSTERIP: check duplicate config when initializing

Now when adding an ipt_CLUSTERIP rule, it only checks duplicate config in
clusterip_config_find_get(). But after that, there may be still another
thread to insert a config with the same ip, then it leaves proc_create_data
to do duplicate check.

It's more reasonable to check duplicate config by ipt_CLUSTERIP itself,
instead of checking it by proc fs duplicate file check. Before, when proc
fs allowed duplicate name files in a directory, It could even crash kernel
because of use-after-free.

This patch is to check duplicate config under the protection of clusterip
net lock when initializing a new config and correct the return err.

Note that it also moves proc file node creation after adding new config, as
proc_create_data may sleep, it couldn't be called under the clusterip_net
lock. clusterip_config_find_get returns NULL if c->pde is null to make sure
it can't be used until the proc file node creation is done.

Suggested-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/netfilter/ipt_CLUSTERIP.c