netfilter: nf_tables: fix potential NULL-ptr deref in nf_tables_dump_obj_done()
Subsystems (2)
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")
Signed-off-by Hangbin Liu <[email protected]>
Acked-by Phil Sutter <[email protected]>
--- net/netfilter/nf_tables_api.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +4 -2
@@ -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
Quoted 3 lines · Hangbin Liu
If there is no
NFTA_OBJ_TABLEandNFTA_OBJ_TYPE, the c.data will be NULL innf_tables_getobj(). So before freefilter->tableinnf_tables_dump_obj_done(), we need to check if filter is NULL first.
Applied, thanks!