* [PATCH] netfilter: nf_tables: Fix a use after free in nft_immediate_destroy()
@ 2020-07-14 10:56 Dan Carpenter
2020-07-15 18:14 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-07-14 10:56 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: Jozsef Kadlecsik, Florian Westphal, Jakub Kicinski,
netfilter-devel, coreteam, kernel-janitors
The nf_tables_rule_release() function frees "rule" so we have to use
the _safe() version of list_for_each_entry().
Fixes: d0e2c7de92c7 ("netfilter: nf_tables: add NFT_CHAIN_BINDING")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
net/netfilter/nft_immediate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nft_immediate.c b/net/netfilter/nft_immediate.c
index 9e556638bb32..c63eb3b17178 100644
--- a/net/netfilter/nft_immediate.c
+++ b/net/netfilter/nft_immediate.c
@@ -103,9 +103,9 @@ static void nft_immediate_destroy(const struct nft_ctx *ctx,
{
const struct nft_immediate_expr *priv = nft_expr_priv(expr);
const struct nft_data *data = &priv->data;
+ struct nft_rule *rule, *n;
struct nft_ctx chain_ctx;
struct nft_chain *chain;
- struct nft_rule *rule;
if (priv->dreg != NFT_REG_VERDICT)
return;
@@ -121,7 +121,7 @@ static void nft_immediate_destroy(const struct nft_ctx *ctx,
chain_ctx = *ctx;
chain_ctx.chain = chain;
- list_for_each_entry(rule, &chain->rules, list)
+ list_for_each_entry_safe(rule, n, &chain->rules, list)
nf_tables_rule_release(&chain_ctx, rule);
nf_tables_chain_destroy(&chain_ctx);
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] netfilter: nf_tables: Fix a use after free in nft_immediate_destroy()
2020-07-14 10:56 [PATCH] netfilter: nf_tables: Fix a use after free in nft_immediate_destroy() Dan Carpenter
@ 2020-07-15 18:14 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2020-07-15 18:14 UTC (permalink / raw)
To: Dan Carpenter
Cc: Jozsef Kadlecsik, Florian Westphal, Jakub Kicinski,
netfilter-devel, coreteam, kernel-janitors
On Tue, Jul 14, 2020 at 01:56:22PM +0300, Dan Carpenter wrote:
> The nf_tables_rule_release() function frees "rule" so we have to use
> the _safe() version of list_for_each_entry().
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-15 18:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14 10:56 [PATCH] netfilter: nf_tables: Fix a use after free in nft_immediate_destroy() Dan Carpenter
2020-07-15 18:14 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).