Skip to content

Commit bbeae3a

Browse files
committed
netfilter: nf_set_pipapo_avx2: fix initial map fill
JIRA: https://issues.redhat.com/browse/RHEL-115630 Upstream Status: commit ea77c39 commit ea77c39 Author: Florian Westphal <fw@strlen.de> Date: Fri May 23 14:20:44 2025 +0200 netfilter: nf_set_pipapo_avx2: fix initial map fill If the first field doesn't cover the entire start map, then we must zero out the remainder, else we leak those bits into the next match round map. The early fix was incomplete and did only fix up the generic C implementation. A followup patch adds a test case to nft_concat_range.sh. Fixes: 791a615 ("netfilter: nf_set_pipapo: fix initial map fill") Signed-off-by: Florian Westphal <fw@strlen.de> Reviewed-by: Stefano Brivio <sbrivio@redhat.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Florian Westphal <fwestpha@redhat.com>
1 parent ef5fcfd commit bbeae3a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

net/netfilter/nft_set_pipapo_avx2.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,25 @@ bool nft_pipapo_avx2_estimate(const struct nft_set_desc *desc, u32 features,
11151115
return true;
11161116
}
11171117

1118+
/**
1119+
* pipapo_resmap_init_avx2() - Initialise result map before first use
1120+
* @m: Matching data, including mapping table
1121+
* @res_map: Result map
1122+
*
1123+
* Like pipapo_resmap_init() but do not set start map bits covered by the first field.
1124+
*/
1125+
static inline void pipapo_resmap_init_avx2(const struct nft_pipapo_match *m, unsigned long *res_map)
1126+
{
1127+
const struct nft_pipapo_field *f = m->f;
1128+
int i;
1129+
1130+
/* Starting map doesn't need to be set to all-ones for this implementation,
1131+
* but we do need to zero the remaining bits, if any.
1132+
*/
1133+
for (i = f->bsize; i < m->bsize_max; i++)
1134+
res_map[i] = 0ul;
1135+
}
1136+
11181137
/**
11191138
* nft_pipapo_avx2_lookup() - Lookup function for AVX2 implementation
11201139
* @net: Network namespace
@@ -1173,7 +1192,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
11731192
res = scratch->map + (map_index ? m->bsize_max : 0);
11741193
fill = scratch->map + (map_index ? 0 : m->bsize_max);
11751194

1176-
/* Starting map doesn't need to be set for this implementation */
1195+
pipapo_resmap_init_avx2(m, res);
11771196

11781197
nft_pipapo_avx2_prepare();
11791198

0 commit comments

Comments
 (0)