[SRU][J/N/Q][PATCH 1/1] netfilter: ipset: drop logically empty buckets in mtype_del
Tim Whisonant
tim.whisonant at canonical.com
Fri Apr 24 16:41:47 UTC 2026
From: Yifan Wu <yifanwucs at gmail.com>
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 at vger.kernel.org
Reported-by: Juefei Pu <tomapufckgml at gmail.com>
Reported-by: Xin Liu <dstsmallbird at foxmail.com>
Signed-off-by: Yifan Wu <yifanwucs at gmail.com>
Co-developed-by: Yuan Tan <yuantan098 at gmail.com>
Signed-off-by: Yuan Tan <yuantan098 at gmail.com>
Reviewed-by: Phil Sutter <phil at nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
(cherry picked from commit 9862ef9ab0a116c6dca98842aab7de13a252ae02)
CVE-2026-31418
Signed-off-by: Tim Whisonant <tim.whisonant at canonical.com>
---
net/netfilter/ipset/ip_set_hash_gen.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 1f9ca5040982d..da7956e2f8d89 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -1086,7 +1086,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);
--
2.43.0
More information about the kernel-team
mailing list