memory leak in nbd_add_socket

From: syzbot
Date: Tue Mar 31 2020 - 13:11:19 EST


Hello,

syzbot found the following crash on:

HEAD commit: 673b41e0 staging/octeon: fix up merge error
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15badadbe00000
kernel config: https://syzkaller.appspot.com/x/.config?x=d97026d04c648459
dashboard link: https://syzkaller.appspot.com/bug?extid=934037347002901b8d2a
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12dbb747e00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14421b9de00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+934037347002901b8d2a@xxxxxxxxxxxxxxxxxxxxxxxxx

BUG: memory leak
unreferenced object 0xffff88810fd584a0 (size 32):
comm "syz-executor586", pid 8424, jiffies 4294961663 (age 40.060s)
hex dump (first 32 bytes):
2f 64 65 76 2f 6e 62 64 30 00 00 00 00 00 00 00 /dev/nbd0.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000090cb73c8>] __do_krealloc mm/slab_common.c:1671 [inline]
[<0000000090cb73c8>] krealloc+0x7c/0xa0 mm/slab_common.c:1700
[<00000000cf9e6ba7>] nbd_add_socket+0x7d/0x1e0 drivers/block/nbd.c:1040
[<0000000040a0a881>] __nbd_ioctl drivers/block/nbd.c:1373 [inline]
[<0000000040a0a881>] nbd_ioctl+0x175/0x430 drivers/block/nbd.c:1437
[<000000004972a55a>] __blkdev_driver_ioctl block/ioctl.c:322 [inline]
[<000000004972a55a>] blkdev_ioctl+0x147/0x300 block/ioctl.c:718
[<000000008903d911>] block_ioctl+0x50/0x70 fs/block_dev.c:1995
[<00000000c37950d9>] vfs_ioctl fs/ioctl.c:47 [inline]
[<00000000c37950d9>] ksys_ioctl+0xa6/0xd0 fs/ioctl.c:763
[<00000000ffe4bbdc>] __do_sys_ioctl fs/ioctl.c:772 [inline]
[<00000000ffe4bbdc>] __se_sys_ioctl fs/ioctl.c:770 [inline]
[<00000000ffe4bbdc>] __x64_sys_ioctl+0x1a/0x20 fs/ioctl.c:770
[<00000000ede38b98>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:294
[<00000000553f73d5>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88810fd584a0 (size 32):
comm "syz-executor586", pid 8424, jiffies 4294961663 (age 40.170s)
hex dump (first 32 bytes):
2f 64 65 76 2f 6e 62 64 30 00 00 00 00 00 00 00 /dev/nbd0.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000090cb73c8>] __do_krealloc mm/slab_common.c:1671 [inline]
[<0000000090cb73c8>] krealloc+0x7c/0xa0 mm/slab_common.c:1700
[<00000000cf9e6ba7>] nbd_add_socket+0x7d/0x1e0 drivers/block/nbd.c:1040
[<0000000040a0a881>] __nbd_ioctl drivers/block/nbd.c:1373 [inline]
[<0000000040a0a881>] nbd_ioctl+0x175/0x430 drivers/block/nbd.c:1437
[<000000004972a55a>] __blkdev_driver_ioctl block/ioctl.c:322 [inline]
[<000000004972a55a>] blkdev_ioctl+0x147/0x300 block/ioctl.c:718
[<000000008903d911>] block_ioctl+0x50/0x70 fs/block_dev.c:1995
[<00000000c37950d9>] vfs_ioctl fs/ioctl.c:47 [inline]
[<00000000c37950d9>] ksys_ioctl+0xa6/0xd0 fs/ioctl.c:763
[<00000000ffe4bbdc>] __do_sys_ioctl fs/ioctl.c:772 [inline]
[<00000000ffe4bbdc>] __se_sys_ioctl fs/ioctl.c:770 [inline]
[<00000000ffe4bbdc>] __x64_sys_ioctl+0x1a/0x20 fs/ioctl.c:770
[<00000000ede38b98>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:294
[<00000000553f73d5>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88810fd584a0 (size 32):
comm "syz-executor586", pid 8424, jiffies 4294961663 (age 40.270s)
hex dump (first 32 bytes):
2f 64 65 76 2f 6e 62 64 30 00 00 00 00 00 00 00 /dev/nbd0.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000090cb73c8>] __do_krealloc mm/slab_common.c:1671 [inline]
[<0000000090cb73c8>] krealloc+0x7c/0xa0 mm/slab_common.c:1700
[<00000000cf9e6ba7>] nbd_add_socket+0x7d/0x1e0 drivers/block/nbd.c:1040
[<0000000040a0a881>] __nbd_ioctl drivers/block/nbd.c:1373 [inline]
[<0000000040a0a881>] nbd_ioctl+0x175/0x430 drivers/block/nbd.c:1437
[<000000004972a55a>] __blkdev_driver_ioctl block/ioctl.c:322 [inline]
[<000000004972a55a>] blkdev_ioctl+0x147/0x300 block/ioctl.c:718
[<000000008903d911>] block_ioctl+0x50/0x70 fs/block_dev.c:1995
[<00000000c37950d9>] vfs_ioctl fs/ioctl.c:47 [inline]
[<00000000c37950d9>] ksys_ioctl+0xa6/0xd0 fs/ioctl.c:763
[<00000000ffe4bbdc>] __do_sys_ioctl fs/ioctl.c:772 [inline]
[<00000000ffe4bbdc>] __se_sys_ioctl fs/ioctl.c:770 [inline]
[<00000000ffe4bbdc>] __x64_sys_ioctl+0x1a/0x20 fs/ioctl.c:770
[<00000000ede38b98>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:294
[<00000000553f73d5>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88810fd584a0 (size 32):
comm "syz-executor586", pid 8424, jiffies 4294961663 (age 40.380s)
hex dump (first 32 bytes):
2f 64 65 76 2f 6e 62 64 30 00 00 00 00 00 00 00 /dev/nbd0.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000090cb73c8>] __do_krealloc mm/slab_common.c:1671 [inline]
[<0000000090cb73c8>] krealloc+0x7c/0xa0 mm/slab_common.c:1700
[<00000000cf9e6ba7>] nbd_add_socket+0x7d/0x1e0 drivers/block/nbd.c:1040
[<0000000040a0a881>] __nbd_ioctl drivers/block/nbd.c:1373 [inline]
[<0000000040a0a881>] nbd_ioctl+0x175/0x430 drivers/block/nbd.c:1437
[<000000004972a55a>] __blkdev_driver_ioctl block/ioctl.c:322 [inline]
[<000000004972a55a>] blkdev_ioctl+0x147/0x300 block/ioctl.c:718
[<000000008903d911>] block_ioctl+0x50/0x70 fs/block_dev.c:1995
[<00000000c37950d9>] vfs_ioctl fs/ioctl.c:47 [inline]
[<00000000c37950d9>] ksys_ioctl+0xa6/0xd0 fs/ioctl.c:763
[<00000000ffe4bbdc>] __do_sys_ioctl fs/ioctl.c:772 [inline]
[<00000000ffe4bbdc>] __se_sys_ioctl fs/ioctl.c:770 [inline]
[<00000000ffe4bbdc>] __x64_sys_ioctl+0x1a/0x20 fs/ioctl.c:770
[<00000000ede38b98>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:294
[<00000000553f73d5>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88810fd584a0 (size 32):
comm "syz-executor586", pid 8424, jiffies 4294961663 (age 40.480s)
hex dump (first 32 bytes):
2f 64 65 76 2f 6e 62 64 30 00 00 00 00 00 00 00 /dev/nbd0.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000090cb73c8>] __do_krealloc mm/slab_common.c:1671 [inline]
[<0000000090cb73c8>] krealloc+0x7c/0xa0 mm/slab_common.c:1700
[<00000000cf9e6ba7>] nbd_add_socket+0x7d/0x1e0 drivers/block/nbd.c:1040
[<0000000040a0a881>] __nbd_ioctl drivers/block/nbd.c:1373 [inline]
[<0000000040a0a881>] nbd_ioctl+0x175/0x430 drivers/block/nbd.c:1437
[<000000004972a55a>] __blkdev_driver_ioctl block/ioctl.c:322 [inline]
[<000000004972a55a>] blkdev_ioctl+0x147/0x300 block/ioctl.c:718
[<000000008903d911>] block_ioctl+0x50/0x70 fs/block_dev.c:1995
[<00000000c37950d9>] vfs_ioctl fs/ioctl.c:47 [inline]
[<00000000c37950d9>] ksys_ioctl+0xa6/0xd0 fs/ioctl.c:763
[<00000000ffe4bbdc>] __do_sys_ioctl fs/ioctl.c:772 [inline]
[<00000000ffe4bbdc>] __se_sys_ioctl fs/ioctl.c:770 [inline]
[<00000000ffe4bbdc>] __x64_sys_ioctl+0x1a/0x20 fs/ioctl.c:770
[<00000000ede38b98>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:294
[<00000000553f73d5>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88810fd584a0 (size 32):
comm "syz-executor586", pid 8424, jiffies 4294961663 (age 40.590s)
hex dump (first 32 bytes):
2f 64 65 76 2f 6e 62 64 30 00 00 00 00 00 00 00 /dev/nbd0.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000090cb73c8>] __do_krealloc mm/slab_common.c:1671 [inline]
[<0000000090cb73c8>] krealloc+0x7c/0xa0 mm/slab_common.c:1700
[<00000000cf9e6ba7>] nbd_add_socket+0x7d/0x1e0 drivers/block/nbd.c:1040
[<0000000040a0a881>] __nbd_ioctl drivers/block/nbd.c:1373 [inline]
[<0000000040a0a881>] nbd_ioctl+0x175/0x430 drivers/block/nbd.c:1437
[<000000004972a55a>] __blkdev_driver_ioctl block/ioctl.c:322 [inline]
[<000000004972a55a>] blkdev_ioctl+0x147/0x300 block/ioctl.c:718
[<000000008903d911>] block_ioctl+0x50/0x70 fs/block_dev.c:1995
[<00000000c37950d9>] vfs_ioctl fs/ioctl.c:47 [inline]
[<00000000c37950d9>] ksys_ioctl+0xa6/0xd0 fs/ioctl.c:763
[<00000000ffe4bbdc>] __do_sys_ioctl fs/ioctl.c:772 [inline]
[<00000000ffe4bbdc>] __se_sys_ioctl fs/ioctl.c:770 [inline]
[<00000000ffe4bbdc>] __x64_sys_ioctl+0x1a/0x20 fs/ioctl.c:770
[<00000000ede38b98>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:294
[<00000000553f73d5>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88810fd584a0 (size 32):
comm "syz-executor586", pid 8424, jiffies 4294961663 (age 40.690s)
hex dump (first 32 bytes):
2f 64 65 76 2f 6e 62 64 30 00 00 00 00 00 00 00 /dev/nbd0.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000090cb73c8>] __do_krealloc mm/slab_common.c:1671 [inline]
[<0000000090cb73c8>] krealloc+0x7c/0xa0 mm/slab_common.c:1700
[<00000000cf9e6ba7>] nbd_add_socket+0x7d/0x1e0 drivers/block/nbd.c:1040
[<0000000040a0a881>] __nbd_ioctl drivers/block/nbd.c:1373 [inline]
[<0000000040a0a881>] nbd_ioctl+0x175/0x430 drivers/block/nbd.c:1437
[<000000004972a55a>] __blkdev_driver_ioctl block/ioctl.c:322 [inline]
[<000000004972a55a>] blkdev_ioctl+0x147/0x300 block/ioctl.c:718
[<000000008903d911>] block_ioctl+0x50/0x70 fs/block_dev.c:1995
[<00000000c37950d9>] vfs_ioctl fs/ioctl.c:47 [inline]
[<00000000c37950d9>] ksys_ioctl+0xa6/0xd0 fs/ioctl.c:763
[<00000000ffe4bbdc>] __do_sys_ioctl fs/ioctl.c:772 [inline]
[<00000000ffe4bbdc>] __se_sys_ioctl fs/ioctl.c:770 [inline]
[<00000000ffe4bbdc>] __x64_sys_ioctl+0x1a/0x20 fs/ioctl.c:770
[<00000000ede38b98>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:294
[<00000000553f73d5>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88810fd584a0 (size 32):
comm "syz-executor586", pid 8424, jiffies 4294961663 (age 40.800s)
hex dump (first 32 bytes):
2f 64 65 76 2f 6e 62 64 30 00 00 00 00 00 00 00 /dev/nbd0.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000090cb73c8>] __do_krealloc mm/slab_common.c:1671 [inline]
[<0000000090cb73c8>] krealloc+0x7c/0xa0 mm/slab_common.c:1700
[<00000000cf9e6ba7>] nbd_add_socket+0x7d/0x1e0 drivers/block/nbd.c:1040
[<0000000040a0a881>] __nbd_ioctl drivers/block/nbd.c:1373 [inline]
[<0000000040a0a881>] nbd_ioctl+0x175/0x430 drivers/block/nbd.c:1437
[<000000004972a55a>] __blkdev_driver_ioctl block/ioctl.c:322 [inline]
[<000000004972a55a>] blkdev_ioctl+0x147/0x300 block/ioctl.c:718
[<000000008903d911>] block_ioctl+0x50/0x70 fs/block_dev.c:1995
[<00000000c37950d9>] vfs_ioctl fs/ioctl.c:47 [inline]
[<00000000c37950d9>] ksys_ioctl+0xa6/0xd0 fs/ioctl.c:763
[<00000000ffe4bbdc>] __do_sys_ioctl fs/ioctl.c:772 [inline]
[<00000000ffe4bbdc>] __se_sys_ioctl fs/ioctl.c:770 [inline]
[<00000000ffe4bbdc>] __x64_sys_ioctl+0x1a/0x20 fs/ioctl.c:770
[<00000000ede38b98>] do_syscall_64+0x6e/0x220 arch/x86/entry/common.c:294
[<00000000553f73d5>] 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@xxxxxxxxxxxxxxxxx

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