]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nf_tables: fix audit memory leak in nf_tables_commit
authorDongliang Mu <mudongliangabcd@gmail.com>
Wed, 14 Jul 2021 03:27:03 +0000 (11:27 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 17 Jul 2021 00:25:18 +0000 (02:25 +0200)
commitcfbe3650dd3ef2ea9a4420ca89d9a4df98af3fb6
tree8738d38fb130cd1daa3ce142ab653f3a54036d2b
parent5f119ba1d5771bbf46d57cff7417dcd84d3084ba
netfilter: nf_tables: fix audit memory leak in nf_tables_commit

In nf_tables_commit, if nf_tables_commit_audit_alloc fails, it does not
free the adp variable.

Fix this by adding nf_tables_commit_audit_free which frees
the linked list with the head node adl.

backtrace:
  kmalloc include/linux/slab.h:591 [inline]
  kzalloc include/linux/slab.h:721 [inline]
  nf_tables_commit_audit_alloc net/netfilter/nf_tables_api.c:8439 [inline]
  nf_tables_commit+0x16e/0x1760 net/netfilter/nf_tables_api.c:8508
  nfnetlink_rcv_batch+0x512/0xa80 net/netfilter/nfnetlink.c:562
  nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:634 [inline]
  nfnetlink_rcv+0x1fa/0x220 net/netfilter/nfnetlink.c:652
  netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline]
  netlink_unicast+0x2c7/0x3e0 net/netlink/af_netlink.c:1340
  netlink_sendmsg+0x36b/0x6b0 net/netlink/af_netlink.c:1929
  sock_sendmsg_nosec net/socket.c:702 [inline]
  sock_sendmsg+0x56/0x80 net/socket.c:722

Reported-by: syzbot <syzkaller@googlegroups.com>
Reported-by: kernel test robot <lkp@intel.com>
Fixes: c520292f29b8 ("audit: log nftables configuration change events once per table")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c