334-v4.15-netfilter-nf_tables-fix-potential-NULL-ptr-deref-in-.patch 892 B

123456789101112131415161718192021222324252627282930
  1. From: Hangbin Liu <liuhangbin@gmail.com>
  2. Date: Mon, 25 Dec 2017 11:34:54 +0800
  3. Subject: [PATCH] netfilter: nf_tables: fix potential NULL-ptr deref in
  4. nf_tables_dump_obj_done()
  5. If there is no NFTA_OBJ_TABLE and NFTA_OBJ_TYPE, the c.data will be NULL in
  6. nf_tables_getobj(). So before free filter->table in nf_tables_dump_obj_done(),
  7. we need to check if filter is NULL first.
  8. Fixes: e46abbcc05aa ("netfilter: nf_tables: Allow table names of up to 255 chars")
  9. Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
  10. Acked-by: Phil Sutter <phil@nwl.cc>
  11. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  12. ---
  13. --- a/net/netfilter/nf_tables_api.c
  14. +++ b/net/netfilter/nf_tables_api.c
  15. @@ -5358,8 +5358,10 @@ static int nf_tables_dump_flowtable_done
  16. if (!filter)
  17. return 0;
  18. - kfree(filter->table);
  19. - kfree(filter);
  20. + if (filter) {
  21. + kfree(filter->table);
  22. + kfree(filter);
  23. + }
  24. return 0;
  25. }