]> git.itanic.dy.fi Git - linux-stable/commitdiff
netfilter: nft_set_pipapo: release elements in clone only from destroy path
authorPablo Neira Ayuso <pablo@netfilter.org>
Sun, 10 Mar 2024 09:02:41 +0000 (10:02 +0100)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:17:37 +0000 (18:17 -0400)
[ Upstream commit b0e256f3dd2ba6532f37c5c22e07cb07a36031ee ]

Clone already always provides a current view of the lookup table, use it
to destroy the set, otherwise it is possible to destroy elements twice.

This fix requires:

 212ed75dc5fb ("netfilter: nf_tables: integrate pipapo into commit protocol")

which came after:

 9827a0e6e23b ("netfilter: nft_set_pipapo: release elements in clone from abort path").

Fixes: 9827a0e6e23b ("netfilter: nft_set_pipapo: release elements in clone from abort path")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nft_set_pipapo.c

index aa1d9e93a9a04859d48e417501c7f9e889187400..b3b282de802def7a01316e5e8ed809ba92d0fd8d 100644 (file)
@@ -2244,8 +2244,6 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
        if (m) {
                rcu_barrier();
 
-               nft_set_pipapo_match_destroy(ctx, set, m);
-
                for_each_possible_cpu(cpu)
                        pipapo_free_scratch(m, cpu);
                free_percpu(m->scratch);
@@ -2257,8 +2255,7 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
        if (priv->clone) {
                m = priv->clone;
 
-               if (priv->dirty)
-                       nft_set_pipapo_match_destroy(ctx, set, m);
+               nft_set_pipapo_match_destroy(ctx, set, m);
 
                for_each_possible_cpu(cpu)
                        pipapo_free_scratch(priv->clone, cpu);