Subject: memory leak in __team_options_register

From: syzbot <[email-masked]>
Date: Mon, 07 Sep 2020 14:19:15 -0700

Hello,

syzbot found the following issue on:

HEAD commit:    f4d51dff Linux 5.9-rc4
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=126a23e1900000
kernel config:  https://syzkaller.appspot.com/x/.config?x=7954285d6e960c0f
dashboard link: https://syzkaller.appspot.com/bug?extid=69b804437cfec30deac3
compiler:       gcc (GCC) 10.1.0-syz 20200507
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1627617d900000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=122e20dd900000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email-masked]

BUG: memory leak
unreferenced object 0xffff8881197f4cc0 (size 64):
  comm "syz-executor772", pid 6506, jiffies 4294951766 (age 20.400s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    41 aa 0c 84 ff ff ff ff 01 00 00 00 00 00 00 00  A...............
  backtrace:
    [<000000000c781965>] kmemdup+0x23/0x50 mm/util.c:127
    [<00000000bdcac628>] kmemdup include/linux/string.h:479 [inline]
    [<00000000bdcac628>] __team_options_register+0xf7/0x2c0 drivers/net/team/team.c:269
    [<00000000d0decc27>] team_options_register drivers/net/team/team.c:340 [inline]
    [<00000000d0decc27>] team_init+0x1b2/0x2f0 drivers/net/team/team.c:1643
    [<00000000b2b1c890>] register_netdevice+0x143/0x760 net/core/dev.c:9760
    [<000000001344192b>] __rtnl_newlink+0x8f0/0xbc0 net/core/rtnetlink.c:3441
    [<00000000254132c3>] rtnl_newlink+0x49/0x70 net/core/rtnetlink.c:3500
    [<000000001566c9e7>] rtnetlink_rcv_msg+0x17e/0x460 net/core/rtnetlink.c:5563
    [<0000000017d9fa2a>] netlink_rcv_skb+0x5b/0x180 net/netlink/af_netlink.c:2470
    [<00000000c4f11d5e>] netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
    [<00000000c4f11d5e>] netlink_unicast+0x2b6/0x3c0 net/netlink/af_netlink.c:1330
    [<0000000066743465>] netlink_sendmsg+0x2ba/0x570 net/netlink/af_netlink.c:1919
    [<000000005d0b195e>] sock_sendmsg_nosec net/socket.c:651 [inline]
    [<000000005d0b195e>] sock_sendmsg+0x4c/0x60 net/socket.c:671
    [<0000000008f94e79>] ____sys_sendmsg+0x118/0x2f0 net/socket.c:2353
    [<00000000e00d63ed>] ___sys_sendmsg+0x81/0xc0 net/socket.c:2407
    [<000000005e9d5313>] __sys_sendmmsg+0xda/0x230 net/socket.c:2497
    [<000000002479ea72>] __do_sys_sendmmsg net/socket.c:2526 [inline]
    [<000000002479ea72>] __se_sys_sendmmsg net/socket.c:2523 [inline]
    [<000000002479ea72>] __x64_sys_sendmmsg+0x24/0x30 net/socket.c:2523
    [<0000000032159aee>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46

BUG: memory leak
unreferenced object 0xffff88811b4e0b80 (size 64):
  comm "syz-executor772", pid 6508, jiffies 4294951886 (age 19.210s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    41 aa 0c 84 ff ff ff ff 01 00 00 00 00 00 00 00  A...............
  backtrace:
    [<000000000c781965>] kmemdup+0x23/0x50 mm/util.c:127
    [<00000000bdcac628>] kmemdup include/linux/string.h:479 [inline]
    [<00000000bdcac628>] __team_options_register+0xf7/0x2c0 drivers/net/team/team.c:269
    [<00000000d0decc27>] team_options_register drivers/net/team/team.c:340 [inline]
    [<00000000d0decc27>] team_init+0x1b2/0x2f0 drivers/net/team/team.c:1643
    [<00000000b2b1c890>] register_netdevice+0x143/0x760 net/core/dev.c:9760
    [<000000001344192b>] __rtnl_newlink+0x8f0/0xbc0 net/core/rtnetlink.c:3441
    [<00000000254132c3>] rtnl_newlink+0x49/0x70 net/core/rtnetlink.c:3500
    [<000000001566c9e7>] rtnetlink_rcv_msg+0x17e/0x460 net/core/rtnetlink.c:5563
    [<0000000017d9fa2a>] netlink_rcv_skb+0x5b/0x180 net/netlink/af_netlink.c:2470
    [<00000000c4f11d5e>] netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
    [<00000000c4f11d5e>] netlink_unicast+0x2b6/0x3c0 net/netlink/af_netlink.c:1330
    [<0000000066743465>] netlink_sendmsg+0x2ba/0x570 net/netlink/af_netlink.c:1919
    [<000000005d0b195e>] sock_sendmsg_nosec net/socket.c:651 [inline]
    [<000000005d0b195e>] sock_sendmsg+0x4c/0x60 net/socket.c:671
    [<0000000008f94e79>] ____sys_sendmsg+0x118/0x2f0 net/socket.c:2353
    [<00000000e00d63ed>] ___sys_sendmsg+0x81/0xc0 net/socket.c:2407
    [<000000005e9d5313>] __sys_sendmmsg+0xda/0x230 net/socket.c:2497
    [<000000002479ea72>] __do_sys_sendmmsg net/socket.c:2526 [inline]
    [<000000002479ea72>] __se_sys_sendmmsg net/socket.c:2523 [inline]
    [<000000002479ea72>] __x64_sys_sendmmsg+0x24/0x30 net/socket.c:2523
    [<0000000032159aee>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46

BUG: memory leak
unreferenced object 0xffff88811b4e03c0 (size 64):
  comm "syz-executor772", pid 6518, jiffies 4294951923 (age 18.840s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    41 aa 0c 84 ff ff ff ff 01 00 00 00 00 00 00 00  A...............
  backtrace:
    [<000000000c781965>] kmemdup+0x23/0x50 mm/util.c:127
    [<00000000bdcac628>] kmemdup include/linux/string.h:479 [inline]
    [<00000000bdcac628>] __team_options_register+0xf7/0x2c0 drivers/net/team/team.c:269
    [<00000000d0decc27>] team_options_register drivers/net/team/team.c:340 [inline]
    [<00000000d0decc27>] team_init+0x1b2/0x2f0 drivers/net/team/team.c:1643
    [<00000000b2b1c890>] register_netdevice+0x143/0x760 net/core/dev.c:9760
    [<000000001344192b>] __rtnl_newlink+0x8f0/0xbc0 net/core/rtnetlink.c:3441
    [<00000000254132c3>] rtnl_newlink+0x49/0x70 net/core/rtnetlink.c:3500
    [<000000001566c9e7>] rtnetlink_rcv_msg+0x17e/0x460 net/core/rtnetlink.c:5563
    [<0000000017d9fa2a>] netlink_rcv_skb+0x5b/0x180 net/netlink/af_netlink.c:2470
    [<00000000c4f11d5e>] netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
    [<00000000c4f11d5e>] netlink_unicast+0x2b6/0x3c0 net/netlink/af_netlink.c:1330
    [<0000000066743465>] netlink_sendmsg+0x2ba/0x570 net/netlink/af_netlink.c:1919
    [<000000005d0b195e>] sock_sendmsg_nosec net/socket.c:651 [inline]
    [<000000005d0b195e>] sock_sendmsg+0x4c/0x60 net/socket.c:671
    [<0000000008f94e79>] ____sys_sendmsg+0x118/0x2f0 net/socket.c:2353
    [<00000000e00d63ed>] ___sys_sendmsg+0x81/0xc0 net/socket.c:2407
    [<000000005e9d5313>] __sys_sendmmsg+0xda/0x230 net/socket.c:2497
    [<000000002479ea72>] __do_sys_sendmmsg net/socket.c:2526 [inline]
    [<000000002479ea72>] __se_sys_sendmmsg net/socket.c:2523 [inline]
    [<000000002479ea72>] __x64_sys_sendmmsg+0x24/0x30 net/socket.c:2523
    [<0000000032159aee>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46

executing program
executing program
executing program
executing program
executing program
executing program
executing program

---
This report 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 [email-masked].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches