Skip to content

Commit 23c5426

Browse files
Florian Westphalummakynes
authored andcommitted
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: 3c4287f ("nf_tables: Add set type for arbitrary concatenation of ranges") Reported-by: etkaar <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Reviewed-by: Stefano Brivio <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 4e1860a commit 23c5426

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

net/netfilter/nft_set_pipapo.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,11 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
12901290
if (!new->scratch_aligned)
12911291
goto out_scratch;
12921292
#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;
12931298

12941299
rcu_head_init(&new->rcu);
12951300

@@ -1334,6 +1339,9 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
13341339
kvfree(dst->lt);
13351340
dst--;
13361341
}
1342+
out_scratch_realloc:
1343+
for_each_possible_cpu(i)
1344+
kfree(*per_cpu_ptr(new->scratch, i));
13371345
#ifdef NFT_PIPAPO_ALIGN
13381346
free_percpu(new->scratch_aligned);
13391347
#endif

0 commit comments

Comments
 (0)