Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Ömer Mete Kaya
Sat, 21 Nov 2026 21:15
[PATCH nf] netfilter: ipset: fix extension leak during hash resize
Author: Ömer Mete Kaya
Date: Sat, 21 Nov 2026 21:15
Date: Sat, 21 Nov 2026 21:15
46 lines
12578 bytes
12578 bytes
During hash table resizing, mtype_resize() skips expired elements
without freeing their extensions. The old table is then destroyed
with ext_destroy=false, so these extensions are never freed.
Fix this by calling ip_set_ext_destroy() on expired elements in the
resize copy loop. The cleanup is done under the region lock with the
bucket re-read into a separate variable to avoid races with
mtype_add() concurrently reusing or reallocating the bucket, while
preserving the original bucket pointer for subsequent loop iterations.
Discovered by Sashiko, not triggered, not runtime tested.
Fixes: 80571a9ea4ca ("netfilter: ipset: Fix hash resizing with comments")
Signed-off-by: Ömer Mete Kaya <omermetekaya0@gmail.com>
---
net/netfilter/ipset/ip_set_hash_gen.h | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 80ca523f304b..47aab02c9d23 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -823,8 +823,19 @@ mtype_resize(struct ip_set *set, bool retried)
if (!test_bit_acquire(j, n->used))
continue;
data = ahash_data(n, j, dsize);
- if (SET_ELEM_EXPIRED(set, data))
+ if (SET_ELEM_EXPIRED(set, data)) {
+ struct hbucket *cur;
+
+ spin_lock_bh(&orig->hregion[r].lock);
+ cur = __ipset_dereference(hbucket(orig, i));
+ if (cur && test_bit(j, cur->used)) {
+ data = ahash_data(cur, j, dsize);
+ if (SET_ELEM_EXPIRED(set, data))
+ ip_set_ext_destroy(set, data);
+ }
+ spin_unlock_bh(&orig->hregion[r].lock);
continue;
+ }
#ifdef IP_SET_HASH_WITH_NETS
/* We have readers running parallel with us,
* so the live data cannot be modified.
--
2.56.0
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads