summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorYifan Wu <yifanwucs@gmail.com>2026-03-30 14:39:24 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-04-11 14:19:32 +0200
commit6cea34d7ec6829b62f521a37a287f670144a2233 (patch)
treeef3f7ccf9d3a62b7e0dae59e0731669080eb6af4 /net
parentaca0938d0bb44b886fa5a2fca1e75c6ee84c88e1 (diff)
downloadlinux-6cea34d7ec6829b62f521a37a287f670144a2233.tar.gz
linux-6cea34d7ec6829b62f521a37a287f670144a2233.tar.bz2
linux-6cea34d7ec6829b62f521a37a287f670144a2233.zip
netfilter: ipset: drop logically empty buckets in mtype_del
commit 9862ef9ab0a116c6dca98842aab7de13a252ae02 upstream. mtype_del() counts empty slots below n->pos in k, but it only drops the bucket when both n->pos and k are zero. This misses buckets whose live entries have all been removed while n->pos still points past deleted slots. Treat a bucket as empty when all positions below n->pos are unused and release it directly instead of shrinking it further. Fixes: 8af1c6fbd923 ("netfilter: ipset: Fix forceadd evaluation path") Cc: stable@vger.kernel.org Reported-by: Juefei Pu <tomapufckgml@gmail.com> Reported-by: Xin Liu <dstsmallbird@foxmail.com> Signed-off-by: Yifan Wu <yifanwucs@gmail.com> Co-developed-by: Yuan Tan <yuantan098@gmail.com> Signed-off-by: Yuan Tan <yuantan098@gmail.com> Reviewed-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/ipset/ip_set_hash_gen.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 20b223e6e93b..9da942070321 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -1098,7 +1098,7 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext,
if (!test_bit(i, n->used))
k++;
}
- if (n->pos == 0 && k == 0) {
+ if (k == n->pos) {
t->hregion[r].ext_size -= ext_size(n->size, dsize);
rcu_assign_pointer(hbucket(t, key), NULL);
kfree_rcu(n, rcu);