]> git.ipfire.org Git - thirdparty/ipset.git/commit
netfilter: ipset: Fix race between IPSET_CMD_CREATE and IPSET_CMD_SWAP
authorJozsef Kadlecsik <kadlec@netfilter.org>
Mon, 18 Sep 2023 21:10:51 +0000 (23:10 +0200)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Mon, 18 Sep 2023 21:10:51 +0000 (23:10 +0200)
commitc63afc87e554f3742b7c2cd9c401cefb632bb38a
treeba7f5022662a2a011c186d36e9c9562463b6bfbe
parent39dfa583c317d6e62290b1276a5b8b58afc7f951
netfilter: ipset: Fix race between IPSET_CMD_CREATE and IPSET_CMD_SWAP

Kyle Zeng reported that there is a race between IPSET_CMD_ADD and IPSET_CMD_SWAP
in netfilter/ip_set, which can lead to the invocation of `__ip_set_put` on a wrong
`set`, triggering the `BUG_ON(set->ref == 0);` check in it.

The race is caused by using the wrong reference counter, i.e. the ref counter instead
of ref_netlink.

Reported-by: Kyle Zeng <zengyhkyle@gmail.com>
Tested-by: Kyle Zeng <zengyhkyle@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
kernel/net/netfilter/ipset/ip_set_core.c