[syzbot] [block?] memory leak in iov_iter_extract_pages

From: syzbot
Date: Wed Aug 16 2023 - 21:56:54 EST


Hello,

syzbot found the following issue on:

HEAD commit: ae545c3283dc Merge tag 'gpio-fixes-for-v6.5-rc6' of git://..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17d1456fa80000
kernel config: https://syzkaller.appspot.com/x/.config?x=2bf8962e4f7984f4
dashboard link: https://syzkaller.appspot.com/bug?extid=cb729843d0f42a5c1a50
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=143edef7a80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16e93037a80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/ab6a1e819c1f/disk-ae545c32.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/55f3314970f5/vmlinux-ae545c32.xz
kernel image: https://storage.googleapis.com/syzbot-assets/1a27c3b2a812/bzImage-ae545c32.xz

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

Warning: Permanently added '10.128.1.14' (ED25519) to the list of known hosts.
executing program
executing program
executing program
BUG: memory leak
unreferenced object 0xffff888109d2e400 (size 1024):
comm "syz-executor121", pid 5006, jiffies 4294943225 (age 17.760s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff81554bbb>] __do_kmalloc_node mm/slab_common.c:984 [inline]
[<ffffffff81554bbb>] __kmalloc_node+0x4b/0x150 mm/slab_common.c:992
[<ffffffff815440f9>] kmalloc_node include/linux/slab.h:602 [inline]
[<ffffffff815440f9>] kvmalloc_node+0x99/0x170 mm/util.c:604
[<ffffffff824c52fe>] kvmalloc include/linux/slab.h:720 [inline]
[<ffffffff824c52fe>] kvmalloc_array include/linux/slab.h:738 [inline]
[<ffffffff824c52fe>] want_pages_array lib/iov_iter.c:985 [inline]
[<ffffffff824c52fe>] iov_iter_extract_user_pages lib/iov_iter.c:1765 [inline]
[<ffffffff824c52fe>] iov_iter_extract_pages+0x1ee/0xa40 lib/iov_iter.c:1831
[<ffffffff824125a7>] bio_map_user_iov+0x167/0x5d0 block/blk-map.c:297
[<ffffffff82412df3>] blk_rq_map_user_iov+0x3e3/0xb30 block/blk-map.c:664
[<ffffffff82413943>] blk_rq_map_user block/blk-map.c:691 [inline]
[<ffffffff82413943>] blk_rq_map_user_io+0x143/0x160 block/blk-map.c:724
[<ffffffff82ca0925>] sg_io+0x285/0x510 drivers/scsi/scsi_ioctl.c:456
[<ffffffff82ca1025>] scsi_cdrom_send_packet+0x1b5/0x480 drivers/scsi/scsi_ioctl.c:820
[<ffffffff82ca13ba>] scsi_ioctl+0xca/0xd30 drivers/scsi/scsi_ioctl.c:903
[<ffffffff82d35964>] sg_ioctl+0x5f4/0x10a0 drivers/scsi/sg.c:1163
[<ffffffff8168e602>] vfs_ioctl fs/ioctl.c:51 [inline]
[<ffffffff8168e602>] __do_sys_ioctl fs/ioctl.c:870 [inline]
[<ffffffff8168e602>] __se_sys_ioctl fs/ioctl.c:856 [inline]
[<ffffffff8168e602>] __x64_sys_ioctl+0xf2/0x140 fs/ioctl.c:856
[<ffffffff84ad2bb8>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff84ad2bb8>] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
[<ffffffff84c0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd

BUG: memory leak
unreferenced object 0xffff888109d2dc00 (size 1024):
comm "syz-executor121", pid 5007, jiffies 4294943747 (age 12.540s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff81554bbb>] __do_kmalloc_node mm/slab_common.c:984 [inline]
[<ffffffff81554bbb>] __kmalloc_node+0x4b/0x150 mm/slab_common.c:992
[<ffffffff815440f9>] kmalloc_node include/linux/slab.h:602 [inline]
[<ffffffff815440f9>] kvmalloc_node+0x99/0x170 mm/util.c:604
[<ffffffff824c52fe>] kvmalloc include/linux/slab.h:720 [inline]
[<ffffffff824c52fe>] kvmalloc_array include/linux/slab.h:738 [inline]
[<ffffffff824c52fe>] want_pages_array lib/iov_iter.c:985 [inline]
[<ffffffff824c52fe>] iov_iter_extract_user_pages lib/iov_iter.c:1765 [inline]
[<ffffffff824c52fe>] iov_iter_extract_pages+0x1ee/0xa40 lib/iov_iter.c:1831
[<ffffffff824125a7>] bio_map_user_iov+0x167/0x5d0 block/blk-map.c:297
[<ffffffff82412df3>] blk_rq_map_user_iov+0x3e3/0xb30 block/blk-map.c:664
[<ffffffff82413943>] blk_rq_map_user block/blk-map.c:691 [inline]
[<ffffffff82413943>] blk_rq_map_user_io+0x143/0x160 block/blk-map.c:724
[<ffffffff82ca0925>] sg_io+0x285/0x510 drivers/scsi/scsi_ioctl.c:456
[<ffffffff82ca1025>] scsi_cdrom_send_packet+0x1b5/0x480 drivers/scsi/scsi_ioctl.c:820
[<ffffffff82ca13ba>] scsi_ioctl+0xca/0xd30 drivers/scsi/scsi_ioctl.c:903
[<ffffffff82d35964>] sg_ioctl+0x5f4/0x10a0 drivers/scsi/sg.c:1163
[<ffffffff8168e602>] vfs_ioctl fs/ioctl.c:51 [inline]
[<ffffffff8168e602>] __do_sys_ioctl fs/ioctl.c:870 [inline]
[<ffffffff8168e602>] __se_sys_ioctl fs/ioctl.c:856 [inline]
[<ffffffff8168e602>] __x64_sys_ioctl+0xf2/0x140 fs/ioctl.c:856
[<ffffffff84ad2bb8>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff84ad2bb8>] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
[<ffffffff84c0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd

BUG: memory leak
unreferenced object 0xffff888109d2d800 (size 1024):
comm "syz-executor121", pid 5010, jiffies 4294944269 (age 7.320s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff81554bbb>] __do_kmalloc_node mm/slab_common.c:984 [inline]
[<ffffffff81554bbb>] __kmalloc_node+0x4b/0x150 mm/slab_common.c:992
[<ffffffff815440f9>] kmalloc_node include/linux/slab.h:602 [inline]
[<ffffffff815440f9>] kvmalloc_node+0x99/0x170 mm/util.c:604
[<ffffffff824c52fe>] kvmalloc include/linux/slab.h:720 [inline]
[<ffffffff824c52fe>] kvmalloc_array include/linux/slab.h:738 [inline]
[<ffffffff824c52fe>] want_pages_array lib/iov_iter.c:985 [inline]
[<ffffffff824c52fe>] iov_iter_extract_user_pages lib/iov_iter.c:1765 [inline]
[<ffffffff824c52fe>] iov_iter_extract_pages+0x1ee/0xa40 lib/iov_iter.c:1831
[<ffffffff824125a7>] bio_map_user_iov+0x167/0x5d0 block/blk-map.c:297
[<ffffffff82412df3>] blk_rq_map_user_iov+0x3e3/0xb30 block/blk-map.c:664
[<ffffffff82413943>] blk_rq_map_user block/blk-map.c:691 [inline]
[<ffffffff82413943>] blk_rq_map_user_io+0x143/0x160 block/blk-map.c:724
[<ffffffff82ca0925>] sg_io+0x285/0x510 drivers/scsi/scsi_ioctl.c:456
[<ffffffff82ca1025>] scsi_cdrom_send_packet+0x1b5/0x480 drivers/scsi/scsi_ioctl.c:820
[<ffffffff82ca13ba>] scsi_ioctl+0xca/0xd30 drivers/scsi/scsi_ioctl.c:903
[<ffffffff82d35964>] sg_ioctl+0x5f4/0x10a0 drivers/scsi/sg.c:1163
[<ffffffff8168e602>] vfs_ioctl fs/ioctl.c:51 [inline]
[<ffffffff8168e602>] __do_sys_ioctl fs/ioctl.c:870 [inline]
[<ffffffff8168e602>] __se_sys_ioctl fs/ioctl.c:856 [inline]
[<ffffffff8168e602>] __x64_sys_ioctl+0xf2/0x140 fs/ioctl.c:856
[<ffffffff84ad2bb8>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff84ad2bb8>] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
[<ffffffff84c0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd



---
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 syzkaller@xxxxxxxxxxxxxxxx.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup