]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: ipset: Fix race between IPSET_CMD_CREATE and IPSET_CMD_SWAP
authorJozsef Kadlecsik <kadlec@netfilter.org>
Tue, 19 Sep 2023 18:04:45 +0000 (20:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Oct 2023 12:56:41 +0000 (14:56 +0200)
commitea5a61d58886ae875f1b4a371999f2a8b58cf26d
treebe1ac2cf1431807864f0be0fb2ad9a221afb221e
parentc4b0facd5c20ceae3d07018a3417f06302fa9cd1
netfilter: ipset: Fix race between IPSET_CMD_CREATE and IPSET_CMD_SWAP

[ Upstream commit 7433b6d2afd512d04398c73aa984d1e285be125b ]

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.

Fixes: 24e227896bbf ("netfilter: ipset: Add schedule point in call_ad().")
Reported-by: Kyle Zeng <zengyhkyle@gmail.com>
Closes: https://lore.kernel.org/netfilter-devel/ZPZqetxOmH+w%2Fmyc@westworld/#r
Tested-by: Kyle Zeng <zengyhkyle@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/ipset/ip_set_core.c