]> git.itanic.dy.fi Git - linux-stable/commitdiff
netfilter: nf_tables: deactivate catchall elements in next generation
authorFlorian Westphal <fw@strlen.de>
Sat, 12 Aug 2023 11:05:16 +0000 (13:05 +0200)
committerFlorian Westphal <fw@strlen.de>
Tue, 15 Aug 2023 22:05:15 +0000 (00:05 +0200)
When flushing, individual set elements are disabled in the next
generation via the ->flush callback.

Catchall elements are not disabled.  This is incorrect and may lead to
double-deactivations of catchall elements which then results in memory
leaks:

WARNING: CPU: 1 PID: 3300 at include/net/netfilter/nf_tables.h:1172 nft_map_deactivate+0x549/0x730
CPU: 1 PID: 3300 Comm: nft Not tainted 6.5.0-rc5+ #60
RIP: 0010:nft_map_deactivate+0x549/0x730
 [..]
 ? nft_map_deactivate+0x549/0x730
 nf_tables_delset+0xb66/0xeb0

(the warn is due to nft_use_dec() detecting underflow).

Fixes: aaa31047a6d2 ("netfilter: nftables: add catch-all set element support")
Reported-by: lonial con <kongln9170@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nf_tables_api.c

index c62227ae7746741f9370204f7be63342de60e10d..6f31022cacc603e9990ed938f27df71eb4d3f182 100644 (file)
@@ -7091,6 +7091,7 @@ static int nft_set_catchall_flush(const struct nft_ctx *ctx,
                ret = __nft_set_catchall_flush(ctx, set, &elem);
                if (ret < 0)
                        break;
+               nft_set_elem_change_active(ctx->net, set, ext);
        }
 
        return ret;