Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nft_set_pipapo: allocate pcpu scratch maps on clone

This is needed in case a new transaction is made that doesn't insert any
new elements into an already existing set.

Else, after second 'nft -f ruleset.txt', lookups in such a set will fail
because ->lookup() encounters raw_cpu_ptr(m->scratch) == NULL.

For the initial rule load, insertion of elements takes care of the
allocation, but for rule reloads this isn't guaranteed: we might not
have additions to the set.

Fixes: 3c4287f62044a90e ("nf_tables: Add set type for arbitrary concatenation of ranges")
Reported-by: etkaar <lists.netfilter.org@prvy.eu>
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Florian Westphal and committed by
Pablo Neira Ayuso
23c54263 4e1860a3

+8
+8
net/netfilter/nft_set_pipapo.c
··· 1290 1290 if (!new->scratch_aligned) 1291 1291 goto out_scratch; 1292 1292 #endif 1293 + for_each_possible_cpu(i) 1294 + *per_cpu_ptr(new->scratch, i) = NULL; 1295 + 1296 + if (pipapo_realloc_scratch(new, old->bsize_max)) 1297 + goto out_scratch_realloc; 1293 1298 1294 1299 rcu_head_init(&new->rcu); 1295 1300 ··· 1339 1334 kvfree(dst->lt); 1340 1335 dst--; 1341 1336 } 1337 + out_scratch_realloc: 1338 + for_each_possible_cpu(i) 1339 + kfree(*per_cpu_ptr(new->scratch, i)); 1342 1340 #ifdef NFT_PIPAPO_ALIGN 1343 1341 free_percpu(new->scratch_aligned); 1344 1342 #endif