Skip to content

Commit 4f18055

Browse files
author
CKI Backport Bot
committed
netfilter: ipset: fix region locking in hash types
JIRA: https://issues.redhat.com/browse/RHEL-115637 commit 8478a72 Author: Jozsef Kadlecsik <kadlec@netfilter.org> Date: Wed May 7 17:01:59 2025 +0200 netfilter: ipset: fix region locking in hash types Region locking introduced in v5.6-rc4 contained three macros to handle the region locks: ahash_bucket_start(), ahash_bucket_end() which gave back the start and end hash bucket values belonging to a given region lock and ahash_region() which should give back the region lock belonging to a given hash bucket. The latter was incorrect which can lead to a race condition between the garbage collector and adding new elements when a hash type of set is defined with timeouts. Fixes: f66ee04 ("netfilter: ipset: Fix "INFO: rcu detected stall in hash_xxx" reports") Reported-by: Kota Toda <kota.toda@gmo-cybersecurity.com> Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
1 parent 6d87b50 commit 4f18055

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/netfilter/ipset/ip_set_hash_gen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct hbucket {
6363
#define ahash_sizeof_regions(htable_bits) \
6464
(ahash_numof_locks(htable_bits) * sizeof(struct ip_set_region))
6565
#define ahash_region(n, htable_bits) \
66-
((n) % ahash_numof_locks(htable_bits))
66+
((n) / jhash_size(HTABLE_REGION_BITS))
6767
#define ahash_bucket_start(h, htable_bits) \
6868
((htable_bits) < HTABLE_REGION_BITS ? 0 \
6969
: (h) * jhash_size(HTABLE_REGION_BITS))

0 commit comments

Comments
 (0)