* [PATCH net] netfilter: ipset: skip inline gc during hash resize
@ 2026-11-17 11:06 Jun Yang
0 siblings, 0 replies; only message in thread
From: Jun Yang @ 2026-11-17 11:06 UTC (permalink / raw)
To: pablo, fw
Cc: phil, davem, edumazet, kuba, pabeni, horms, kadlec, echaudro,
aconole, david.lee, manizada, yifanwucs, netfilter-devel,
coreteam, netdev, junvyyang, corvus, stable
From: Jun Yang <junvyyang@tencent.com>
When the xtables SET target adds an element to a full hash region,
mtype_add() runs garbage collection on that region. If mtype_resize()
has already copied a live element, both tables point to the same
comment. If the element then expires, inline GC can free the comment
in the old table. Destroying the set frees it again in the new table.
Take h->gc.lock and check t->resizing before running inline GC, as
the periodic GC worker does. Resize sets the flag under the same lock
before it starts copying elements.
Fixes: cffcf57bf03c ("netfilter: ipset: exclude gc when resize is in progress")
Cc: stable@kernel.org
Reported-by: TencentOS Corvus AI <corvus@tencent.com>
Signed-off-by: Jun Yang <junvyyang@tencent.com>
---
A KASAN reproducer for this issue is available if requested.
net/netfilter/ipset/ip_set_hash_gen.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 80ca523f304bb..70f768ba7b443 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -1009,8 +1009,12 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,
maxelem = t->maxelem;
if (elements >= maxelem) {
u32 e;
- if (SET_WITH_TIMEOUT(set))
- mtype_gc_do(set, h, t, r);
+ if (SET_WITH_TIMEOUT(set)) {
+ spin_lock_bh(&h->gc.lock);
+ if (!t->resizing)
+ mtype_gc_do(set, h, t, r);
+ spin_unlock_bh(&h->gc.lock);
+ }
maxelem = h->maxelem;
elements = 0;
for (e = 0; e < ahash_numof_locks(t->htable_bits); e++)
--
2.54.0 (Apple Git-157)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-17 11:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 11:06 [PATCH net] netfilter: ipset: skip inline gc during hash resize Jun Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox