Skip to contentSkip to conversation

netfilter: free chain context when BINDING flag is missing

PATCH Applied Florian Westphal 2 participants 2 messages Aug 11, 2020 – Aug 13, 2020

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: 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]
---
 net/netfilter/nf_tables_api.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +4 -2
index d878e34e3354..fd814e514f94 100644
@@ -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);
Signature · 1 line
2.26.2
maintainer Applied
#1 lore raw
Quoted 2 lines · Florian Westphal

syzbot found a memory leak in nf_tables_addchain() because the chain object is not free'd correctly on error.

Applied, thanks.