]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
netfilter: ipset: exclude gc when resize is in progress
authorJozsef Kadlecsik <kadlec@netfilter.org>
Thu, 2 Jul 2026 13:46:58 +0000 (15:46 +0200)
committerFlorian Westphal <fw@strlen.de>
Wed, 8 Jul 2026 13:33:43 +0000 (15:33 +0200)
commitcffcf57bf03cb7f7e83d10f760b5f34e5c51d9b3
tree713bd6ca2ef3c591327e8b7045ee79736142fff0
parent5d0c22e73656d050daffad10a2ba8765ce8441c8
netfilter: ipset: exclude gc when resize is in progress

Zhengchuan Liang and Eulgyu Kim reported that because resize
does not copy the comment extension into the resized set but
uses it's pointer, ongoing gc can free the extension in the
original set which then results stale pointer in the resized
one. The proposed patch was to recreate the extensions for
every element in the resized set. It is both expensive and
wastes memory, so better exclude gc when resizing in progress
detected: resizing will destroy the original set anyway,
so doing gc on it is unnecessary.

Introduce a new spinlock to exclude parallel gc and resize.
Because we just set and check a bool value, there's no need
for the parameter to be atomic_t and rename it for better
readability.

Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Reported-by: Xin Liu <bird@lzu.edu.cn>
Reported by: Zhengchuan Liang <zcliangcn@gmail.com>
Reported by: Eulgyu Kim <eulgyukim@snu.ac.kr>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/ipset/ip_set_hash_gen.h