]> www.infradead.org Git - users/dwmw2/linux.git/commit
netfilter: nf_set_pipapo: fix initial map fill
authorFlorian Westphal <fw@strlen.de>
Mon, 15 Jul 2024 11:54:03 +0000 (13:54 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 17 Jul 2024 17:00:47 +0000 (19:00 +0200)
commit791a615b7ad2258c560f91852be54b0480837c93
tree71e0f470feef028124a2acb83b0daca479a46d50
parent782161895eb4ac45cf7cfa8db375bd4766cb8299
netfilter: nf_set_pipapo: fix initial map fill

The initial buffer has to be inited to all-ones, but it must restrict
it to the size of the first field, not the total field size.

After each round in the map search step, the result and the fill map
are swapped, so if we have a set where f->bsize of the first element
is smaller than m->bsize_max, those one-bits are leaked into future
rounds result map.

This makes pipapo find an incorrect matching results for sets where
first field size is not the largest.

Followup patch adds a test case to nft_concat_range.sh selftest script.

Thanks to Stefano Brivio for pointing out that we need to zero out
the remainder explicitly, only correcting memset() argument isn't enough.

Fixes: 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation of ranges")
Reported-by: Yi Chen <yiche@redhat.com>
Cc: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_set_pipapo.c
net/netfilter/nft_set_pipapo.h
net/netfilter/nft_set_pipapo_avx2.c