Skip to content

Commit 9862ef9

Browse files
GhostFrankWuummakynes
authored andcommitted
netfilter: ipset: drop logically empty buckets in mtype_del
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: 8af1c6f ("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>
1 parent 917b61f commit 9862ef9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

net/netfilter/ipset/ip_set_hash_gen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext,
10981098
if (!test_bit(i, n->used))
10991099
k++;
11001100
}
1101-
if (n->pos == 0 && k == 0) {
1101+
if (k == n->pos) {
11021102
t->hregion[r].ext_size -= ext_size(n->size, dsize);
11031103
rcu_assign_pointer(hbucket(t, key), NULL);
11041104
kfree_rcu(n, rcu);

0 commit comments

Comments
 (0)