]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netfilter: nft_set_pipapo: don't leak bad clone into future transaction
authorFlorian Westphal <fw@strlen.de>
Tue, 16 Jun 2026 11:26:26 +0000 (13:26 +0200)
committerFlorian Westphal <fw@strlen.de>
Tue, 30 Jun 2026 04:37:07 +0000 (06:37 +0200)
commit47e65eff50691f0a5b79d325e28d83ec1da43bcf
treefdd8d78e50193ef218ab7cef4b441ac283554224
parent241ccd2fed9051db443aadce248fc0ab30f55e97
netfilter: nft_set_pipapo: don't leak bad clone into future transaction

On memory allocation failure the cloned nft_pipapo_match can enter a bad
state:
 - some fields can have their lookup tables resized while others did
   not
 - bits might have been toggled
 - scratch map can be undersized which also means m->bsize_max can be
   lower than what is required

This means that the next insertion in the same batch can trigger
out-of-bounds writes.

Furthermore, a failure in the first can result in the bad clone to
leak into the next transaction because the abort callback is never
executed in this case (the upper layer saw an error and no attempt to
allocate a transactional request was made).

Record a state for the nft_pipapo_match structure:
- NEW (pristine clone)
- MOD (modified clone with good state)
- ERR (potentially bogus content)

Then make it so that deletes and insertions fail when the clone
entered ERR state.

In case the very first insert attempt results in an error, free the
clone right away.

Fixes: 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation of ranges")
Cc: stable@vger.kernel.org
Reported-and-tested-by: Seesee <cjc000013@gmail.com>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nft_set_pipapo.c
net/netfilter/nft_set_pipapo.h