diff options
| author | Florian Westphal <[email protected]> | 2020-08-11 19:39:09 +0200 |
|---|---|---|
| committer | Pablo Neira Ayuso <[email protected]> | 2020-08-13 04:17:46 +0200 |
| commit | 59136aa3b2649796a3a1fd90158675f1f640ce0e (patch) | |
| tree | 089f379fd710cc74199b32745bd6f22e102d2cea | |
| parent | 2404b73c3f1a5f15726c6ecd226b56f6f992767f (diff) | |
netfilter: nf_tables: free chain context when BINDING flag is missing
syzbot found a memory leak in nf_tables_addchain() because the chain
object is not free'd correctly on error.
Fixes: d0e2c7de92c7 ("netfilter: nf_tables: add NFT_CHAIN_BINDING")
Reported-by: [email protected]
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
| -rw-r--r-- | net/netfilter/nf_tables_api.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index d878e34e3354..fd814e514f94 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -2018,8 +2018,10 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask, if (nla[NFTA_CHAIN_NAME]) { chain->name = nla_strdup(nla[NFTA_CHAIN_NAME], GFP_KERNEL); } else { - if (!(flags & NFT_CHAIN_BINDING)) - return -EINVAL; + if (!(flags & NFT_CHAIN_BINDING)) { + err = -EINVAL; + goto err1; + } snprintf(name, sizeof(name), "__chain%llu", ++chain_id); chain->name = kstrdup(name, GFP_KERNEL); |