* memory leak in nf_tables_parse_netdev_hooks (3)
@ 2020-06-09 21:58 syzbot
2020-06-09 22:32 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: syzbot @ 2020-06-09 21:58 UTC (permalink / raw)
To: coreteam, davem, fw, kadlec, kuba, linux-kernel, netdev,
netfilter-devel, pablo, syzkaller-bugs
Hello,
syzbot found the following crash on:
HEAD commit: 7ae77150 Merge tag 'powerpc-5.8-1' of git://git.kernel.org..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1741f5f2100000
kernel config: https://syzkaller.appspot.com/x/.config?x=9a1aa05456dfd557
dashboard link: https://syzkaller.appspot.com/bug?extid=eb9d5924c51d6d59e094
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=126f5446100000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=177f16fe100000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+eb9d5924c51d6d59e094@syzkaller.appspotmail.com
executing program
BUG: memory leak
unreferenced object 0xffff88811589cd80 (size 96):
comm "syz-executor337", pid 6663, jiffies 4294942418 (age 13.980s)
hex dump (first 32 bytes):
00 c9 89 15 81 88 ff ff 68 f9 ff 00 00 c9 ff ff ........h.......
00 cd 89 15 81 88 ff ff 60 52 c5 82 ff ff ff ff ........`R......
backtrace:
[<00000000104a1f01>] kmalloc include/linux/slab.h:555 [inline]
[<00000000104a1f01>] nft_netdev_hook_alloc+0x3b/0xd0 net/netfilter/nf_tables_api.c:1659
[<000000003bc42f25>] nf_tables_parse_netdev_hooks+0x94/0x210 net/netfilter/nf_tables_api.c:1709
[<000000004b6a9590>] nft_flowtable_parse_hook+0x101/0x1d0 net/netfilter/nf_tables_api.c:6243
[<000000004204916e>] nft_delflowtable_hook net/netfilter/nf_tables_api.c:6562 [inline]
[<000000004204916e>] nf_tables_delflowtable+0x249/0x4a0 net/netfilter/nf_tables_api.c:6640
[<00000000fa0bd6d2>] nfnetlink_rcv_batch+0x2f3/0x810 net/netfilter/nfnetlink.c:433
[<000000004d4e8df7>] nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:543 [inline]
[<000000004d4e8df7>] nfnetlink_rcv+0x183/0x1b0 net/netfilter/nfnetlink.c:561
[<000000001710060c>] netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
[<000000001710060c>] netlink_unicast+0x20a/0x2f0 net/netlink/af_netlink.c:1329
[<00000000bb814b80>] netlink_sendmsg+0x2b5/0x560 net/netlink/af_netlink.c:1918
[<00000000eb7a00fe>] sock_sendmsg_nosec net/socket.c:652 [inline]
[<00000000eb7a00fe>] sock_sendmsg+0x4c/0x60 net/socket.c:672
[<000000008cc37c52>] ____sys_sendmsg+0x2c4/0x2f0 net/socket.c:2352
[<00000000b882e46e>] ___sys_sendmsg+0x8a/0xd0 net/socket.c:2406
[<00000000870e7750>] __sys_sendmsg+0x77/0xe0 net/socket.c:2439
[<000000002b222e75>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:295
[<00000000356e1a8a>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
BUG: memory leak
unreferenced object 0xffff88811589c900 (size 96):
comm "syz-executor337", pid 6663, jiffies 4294942418 (age 13.980s)
hex dump (first 32 bytes):
68 f9 ff 00 00 c9 ff ff 80 cd 89 15 81 88 ff ff h...............
00 00 00 00 00 00 00 00 60 52 c5 82 ff ff ff ff ........`R......
backtrace:
[<00000000104a1f01>] kmalloc include/linux/slab.h:555 [inline]
[<00000000104a1f01>] nft_netdev_hook_alloc+0x3b/0xd0 net/netfilter/nf_tables_api.c:1659
[<000000003bc42f25>] nf_tables_parse_netdev_hooks+0x94/0x210 net/netfilter/nf_tables_api.c:1709
[<000000004b6a9590>] nft_flowtable_parse_hook+0x101/0x1d0 net/netfilter/nf_tables_api.c:6243
[<000000004204916e>] nft_delflowtable_hook net/netfilter/nf_tables_api.c:6562 [inline]
[<000000004204916e>] nf_tables_delflowtable+0x249/0x4a0 net/netfilter/nf_tables_api.c:6640
[<00000000fa0bd6d2>] nfnetlink_rcv_batch+0x2f3/0x810 net/netfilter/nfnetlink.c:433
[<000000004d4e8df7>] nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:543 [inline]
[<000000004d4e8df7>] nfnetlink_rcv+0x183/0x1b0 net/netfilter/nfnetlink.c:561
[<000000001710060c>] netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
[<000000001710060c>] netlink_unicast+0x20a/0x2f0 net/netlink/af_netlink.c:1329
[<00000000bb814b80>] netlink_sendmsg+0x2b5/0x560 net/netlink/af_netlink.c:1918
[<00000000eb7a00fe>] sock_sendmsg_nosec net/socket.c:652 [inline]
[<00000000eb7a00fe>] sock_sendmsg+0x4c/0x60 net/socket.c:672
[<000000008cc37c52>] ____sys_sendmsg+0x2c4/0x2f0 net/socket.c:2352
[<00000000b882e46e>] ___sys_sendmsg+0x8a/0xd0 net/socket.c:2406
[<00000000870e7750>] __sys_sendmsg+0x77/0xe0 net/socket.c:2439
[<000000002b222e75>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:295
[<00000000356e1a8a>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
BUG: memory leak
unreferenced object 0xffff888115961800 (size 96):
comm "syz-executor337", pid 6664, jiffies 4294943010 (age 8.060s)
hex dump (first 32 bytes):
00 19 96 15 81 88 ff ff 68 f9 ff 00 00 c9 ff ff ........h.......
00 00 00 00 00 00 00 00 60 52 c5 82 ff ff ff ff ........`R......
backtrace:
[<00000000104a1f01>] kmalloc include/linux/slab.h:555 [inline]
[<00000000104a1f01>] nft_netdev_hook_alloc+0x3b/0xd0 net/netfilter/nf_tables_api.c:1659
[<000000003bc42f25>] nf_tables_parse_netdev_hooks+0x94/0x210 net/netfilter/nf_tables_api.c:1709
[<000000004b6a9590>] nft_flowtable_parse_hook+0x101/0x1d0 net/netfilter/nf_tables_api.c:6243
[<000000004204916e>] nft_delflowtable_hook net/netfilter/nf_tables_api.c:6562 [inline]
[<000000004204916e>] nf_tables_delflowtable+0x249/0x4a0 net/netfilter/nf_tables_api.c:6640
[<00000000fa0bd6d2>] nfnetlink_rcv_batch+0x2f3/0x810 net/netfilter/nfnetlink.c:433
[<000000004d4e8df7>] nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:543 [inline]
[<000000004d4e8df7>] nfnetlink_rcv+0x183/0x1b0 net/netfilter/nfnetlink.c:561
[<000000001710060c>] netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
[<000000001710060c>] netlink_unicast+0x20a/0x2f0 net/netlink/af_netlink.c:1329
[<00000000bb814b80>] netlink_sendmsg+0x2b5/0x560 net/netlink/af_netlink.c:1918
[<00000000eb7a00fe>] sock_sendmsg_nosec net/socket.c:652 [inline]
[<00000000eb7a00fe>] sock_sendmsg+0x4c/0x60 net/socket.c:672
[<000000008cc37c52>] ____sys_sendmsg+0x2c4/0x2f0 net/socket.c:2352
[<00000000b882e46e>] ___sys_sendmsg+0x8a/0xd0 net/socket.c:2406
[<00000000870e7750>] __sys_sendmsg+0x77/0xe0 net/socket.c:2439
[<000000002b222e75>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:295
[<00000000356e1a8a>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: memory leak in nf_tables_parse_netdev_hooks (3) 2020-06-09 21:58 memory leak in nf_tables_parse_netdev_hooks (3) syzbot @ 2020-06-09 22:32 ` Pablo Neira Ayuso 0 siblings, 0 replies; 2+ messages in thread From: Pablo Neira Ayuso @ 2020-06-09 22:32 UTC (permalink / raw) To: syzbot Cc: coreteam, davem, fw, kadlec, kuba, linux-kernel, netdev, netfilter-devel, syzkaller-bugs [-- Attachment #1: Type: text/plain, Size: 865 bytes --] On Tue, Jun 09, 2020 at 02:58:12PM -0700, syzbot wrote: > Hello, > > syzbot found the following crash on: > > HEAD commit: 7ae77150 Merge tag 'powerpc-5.8-1' of git://git.kernel.org.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=1741f5f2100000 > kernel config: https://syzkaller.appspot.com/x/.config?x=9a1aa05456dfd557 > dashboard link: https://syzkaller.appspot.com/bug?extid=eb9d5924c51d6d59e094 > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=126f5446100000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=177f16fe100000 > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: syzbot+eb9d5924c51d6d59e094@syzkaller.appspotmail.com Attaching a quick patch, I will have a closer look later. [-- Attachment #2: x.patch --] [-- Type: text/x-diff, Size: 2069 bytes --] diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 073aa1051d43..5792e9dcd9bc 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -6550,12 +6550,22 @@ static int nf_tables_newflowtable(struct net *net, struct sock *nlsk, return err; } +static void nft_flowtable_hook_release(struct nft_flowtable_hook *flowtable_hook) +{ + struct nft_hook *this, *next; + + list_for_each_entry_safe(this, next, &flowtable_hook->list, list) { + list_del(&this->list); + kfree(this); + } +} + static int nft_delflowtable_hook(struct nft_ctx *ctx, struct nft_flowtable *flowtable) { const struct nlattr * const *nla = ctx->nla; struct nft_flowtable_hook flowtable_hook; - struct nft_hook *this, *next, *hook; + struct nft_hook *this, *hook; struct nft_trans *trans; int err; @@ -6564,33 +6574,40 @@ static int nft_delflowtable_hook(struct nft_ctx *ctx, if (err < 0) return err; - list_for_each_entry_safe(this, next, &flowtable_hook.list, list) { + list_for_each_entry(this, &flowtable_hook.list, list) { hook = nft_hook_list_find(&flowtable->hook_list, this); if (!hook) { err = -ENOENT; goto err_flowtable_del_hook; } hook->inactive = true; - list_del(&this->list); - kfree(this); } trans = nft_trans_alloc(ctx, NFT_MSG_DELFLOWTABLE, sizeof(struct nft_trans_flowtable)); - if (!trans) - return -ENOMEM; + if (!trans) { + err = -ENOMEM; + goto err_flowtable_del_hook; + } nft_trans_flowtable(trans) = flowtable; nft_trans_flowtable_update(trans) = true; INIT_LIST_HEAD(&nft_trans_flowtable_hooks(trans)); + nft_flowtable_hook_release(&flowtable_hook); list_add_tail(&trans->list, &ctx->net->nft.commit_list); return 0; err_flowtable_del_hook: - list_for_each_entry(hook, &flowtable_hook.list, list) + list_for_each_entry(this, &flowtable->hook_list, list) { + hook = nft_hook_list_find(&flowtable->hook_list, this); + if (!hook) + break; + hook->inactive = false; + } + nft_flowtable_hook_release(&flowtable_hook); return err; } ^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-09 22:32 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-06-09 21:58 memory leak in nf_tables_parse_netdev_hooks (3) syzbot 2020-06-09 22:32 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).