Skip to content

Commit

Permalink
netfilter: nf_tables: fix double-free on set expression from the erro…
Browse files Browse the repository at this point in the history
…r path

After copying the expression to the set element extension, release the
expression and reset the pointer to avoid a double-free from the error
path.

Fixes: 4094445 ("netfilter: nf_tables: add elements with stateful expressions")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Pablo Neira Ayuso committed Mar 19, 2020
1 parent 6503842 commit 772f4e8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/netfilter/nf_tables_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -5133,6 +5133,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
if (expr) {
memcpy(nft_set_ext_expr(ext), expr, expr->ops->size);
kfree(expr);
expr = NULL;
}

trans = nft_trans_elem_alloc(ctx, NFT_MSG_NEWSETELEM, set);
Expand Down

0 comments on commit 772f4e8

Please sign in to comment.