Skip to contentSkip to conversation

netfilter: nf_tables: fix potential NULL-ptr deref in nf_tables_dump_obj_done()

PATCH Applied Hangbin Liu 2 participants 2 messages Dec 25, 2017 – Dec 26, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nf_tables: fix potential NULL-ptr deref in nf_tables_dump_obj_done()

If there is no NFTA_OBJ_TABLE and NFTA_OBJ_TYPE, the c.data will be NULL in nf_tables_getobj(). So before free filter->table in nf_tables_dump_obj_done(), we need to check if filter is NULL first.

Fixes e46abbcc05aa ("netfilter: nf_tables: Allow table names of up to 255 chars")
---
 net/netfilter/nf_tables_api.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +4 -2
index 10798b3..bfaa320 100644
@@ -4665,8 +4665,10 @@ static int nf_tables_dump_obj_done(struct netlink_callback *cb)
 {
 	struct nft_obj_filter *filter = cb->data;
 
-	kfree(filter->table);
-	kfree(filter);
+	if (filter) {
+		kfree(filter->table);
+		kfree(filter);
+	}
 
 	return 0;
 }
Signature · 1 line
2.5.5
maintainer Applied
#1 lore raw
Quoted 3 lines · Hangbin Liu

If there is no NFTA_OBJ_TABLE and NFTA_OBJ_TYPE, the c.data will be NULL in nf_tables_getobj(). So before free filter->table in nf_tables_dump_obj_done(), we need to check if filter is NULL first.

Applied, thanks!