netfilter: ipset: drop logically empty buckets in mtype_del
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH RESEND 1/1 netfilter: ipset: drop logically empty buckets in mtype_del
From: Yifan Wu <[email protected]>
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.
--- net/netfilter/ipset/ip_set_hash_gen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipset/ip_set_hash_gen.h +1 -1
@@ -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);
Signature · 1 line
2.43.0
Quoted 9 lines · Yuan Tan
From: Yifan Wu <[email protected]>
mtype_del()counts empty slots belown->posin k, but it only drops the bucket when bothn->posand k are zero. This misses buckets whose live entries have all been removed whilen->posstill points past deleted slots.Treat a bucket as empty when all positions below
n->posare unused and release it directly instead of shrinking it further.
Quoted 7 lines
Fixes 8af1c6fbd923 ("netfilter: ipset: Fix forceadd evaluation path")Reported-by Juefei Pu <[email protected]>Reported-by Xin Liu <[email protected]>Signed-off-by Yifan Wu <[email protected]>Co-developed-by Yuan Tan <[email protected]>Signed-off-by Yuan Tan <[email protected]>