Skip to content

Commit 7bc5100

Browse files
Jozsef KadlecsikSasha Levin
authored andcommitted
netfilter: ipset: fix region locking in hash types
[ Upstream commit 8478a72 ] 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: Sasha Levin <sashal@kernel.org>
1 parent 88f72fc commit 7bc5100

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
@@ -64,7 +64,7 @@ struct hbucket {
6464
#define ahash_sizeof_regions(htable_bits) \
6565
(ahash_numof_locks(htable_bits) * sizeof(struct ip_set_region))
6666
#define ahash_region(n, htable_bits) \
67-
((n) % ahash_numof_locks(htable_bits))
67+
((n) / jhash_size(HTABLE_REGION_BITS))
6868
#define ahash_bucket_start(h, htable_bits) \
6969
((htable_bits) < HTABLE_REGION_BITS ? 0 \
7070
: (h) * jhash_size(HTABLE_REGION_BITS))

0 commit comments

Comments
 (0)