]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: nf_tables: fix memory leak in nf_tables_parse_netdev_hooks()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 16 Jan 2020 10:09:31 +0000 (13:09 +0300)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 16 Jan 2020 13:22:32 +0000 (14:22 +0100)
Syzbot detected a leak in nf_tables_parse_netdev_hooks().  If the hook
already exists, then the error handling doesn't free the newest "hook".

Reported-by: syzbot+f9d4095107fc8749c69c@syzkaller.appspotmail.com
Fixes: 9da2c8215737 ("netfilter: nf_tables: allow netdevice to be used only once per flowtable")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index b3692458d428e06e7b56fec3c3302c98ab610631..896a6e8aff9146d39e43233d0cd16508f05a5726 100644 (file)
@@ -1680,6 +1680,7 @@ static int nf_tables_parse_netdev_hooks(struct net *net,
                        goto err_hook;
                }
                if (nft_hook_list_find(hook_list, hook)) {
+                       kfree(hook);
                        err = -EEXIST;
                        goto err_hook;
                }