syzbot


KASAN: use-after-free Read in blkdev_get

Status: upstream: reported C repro on 2019/12/23 13:45
Reported-by: syzbot+95b294092411849b2ac1@syzkaller.appspotmail.com
First crash: 921d, last: 812d

Fix bisection: failed (bisect log)
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in blkdev_get C done error 117 768d 1479d 0/22 upstream: reported C repro on 2018/06/13 16:27
linux-4.14 KASAN: use-after-free Read in blkdev_get syz error 8 742d 920d 0/1 upstream: reported syz repro on 2019/12/24 19:21

Sample crash report:
md: could not open unknown-block(8,3).
md: md_import_device returned -6
md: could not open unknown-block(8,3).
md: md_import_device returned -6
==================================================================
BUG: KASAN: use-after-free in atomic64_read include/asm-generic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in atomic_long_read include/asm-generic/atomic-long.h:47 [inline]
BUG: KASAN: use-after-free in __mutex_unlock_slowpath+0x9b/0x6b0 kernel/locking/mutex.c:1206
Read of size 8 at addr ffff888068bd4818 by task syz-executor769/3049

CPU: 1 PID: 3049 Comm: syz-executor769 Not tainted 4.19.98-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x197/0x210 lib/dump_stack.c:118
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x123/0x190 mm/kasan/kasan.c:267
 kasan_check_read+0x11/0x20 mm/kasan/kasan.c:272
 atomic64_read include/asm-generic/atomic-instrumented.h:27 [inline]
 atomic_long_read include/asm-generic/atomic-long.h:47 [inline]
 __mutex_unlock_slowpath+0x9b/0x6b0 kernel/locking/mutex.c:1206
 mutex_unlock+0xd/0x10 kernel/locking/mutex.c:713
 blkdev_get+0x5a4/0x990 fs/block_dev.c:1671
 blkdev_get_by_dev+0x42/0x80 fs/block_dev.c:1750
 lock_rdev+0xa0/0x160 drivers/md/md.c:2307
 md_import_device+0x221/0x520 drivers/md/md.c:3488
 add_new_disk+0x593/0x18c0 drivers/md/md.c:6347
 md_ioctl+0x45d4/0x5980 drivers/md/md.c:7365
 __blkdev_driver_ioctl block/ioctl.c:303 [inline]
 blkdev_ioctl+0xc2c/0x1ab3 block/ioctl.c:601
 block_ioctl+0xee/0x130 fs/block_dev.c:1894
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:501 [inline]
 do_vfs_ioctl+0xd5f/0x1380 fs/ioctl.c:688
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:705
 __do_sys_ioctl fs/ioctl.c:712 [inline]
 __se_sys_ioctl fs/ioctl.c:710 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:710
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x44ad89
Code: e8 7c e6 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 1b 05 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fba13f00ce8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000006e7a08 RCX: 000000000044ad89
RDX: 0000000020001200 RSI: 0000000040140921 RDI: 0000000000000005
RBP: 00000000006e7a00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006e7a0c
R13: 00007ffe7b20a92f R14: 00007fba13f019c0 R15: 0000000000000000

Allocated by task 3049:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
 kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:490
 kmem_cache_alloc+0x12e/0x700 mm/slab.c:3559
 bdev_alloc_inode+0x1c/0x50 fs/block_dev.c:744
 alloc_inode+0x64/0x190 fs/inode.c:210
 iget5_locked fs/inode.c:1130 [inline]
 iget5_locked+0x63/0xe0 fs/inode.c:1123
 bdget+0x97/0x550 fs/block_dev.c:885
 blkdev_get_by_dev+0x27/0x80 fs/block_dev.c:1746
 lock_rdev+0xa0/0x160 drivers/md/md.c:2307
 md_import_device+0x221/0x520 drivers/md/md.c:3488
 add_new_disk+0x593/0x18c0 drivers/md/md.c:6347
 md_ioctl+0x45d4/0x5980 drivers/md/md.c:7365
 __blkdev_driver_ioctl block/ioctl.c:303 [inline]
 blkdev_ioctl+0xc2c/0x1ab3 block/ioctl.c:601
 block_ioctl+0xee/0x130 fs/block_dev.c:1894
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:501 [inline]
 do_vfs_ioctl+0xd5f/0x1380 fs/ioctl.c:688
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:705
 __do_sys_ioctl fs/ioctl.c:712 [inline]
 __se_sys_ioctl fs/ioctl.c:710 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:710
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 3054:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3503 [inline]
 kmem_cache_free+0x86/0x260 mm/slab.c:3765
 bdev_i_callback+0x20/0x30 fs/block_dev.c:755
 __rcu_reclaim kernel/rcu/rcu.h:236 [inline]
 rcu_do_batch kernel/rcu/tree.c:2584 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
 rcu_process_callbacks+0xba0/0x1a30 kernel/rcu/tree.c:2881
 __do_softirq+0x25c/0x921 kernel/softirq.c:292

The buggy address belongs to the object at ffff888068bd4800
 which belongs to the cache bdev_cache(33:syz3) of size 1344
The buggy address is located 24 bytes inside of
 1344-byte region [ffff888068bd4800, ffff888068bd4d40)
The buggy address belongs to the page:
page:ffffea0001a2f500 count:1 mapcount:0 mapping:ffff88809f983080 index:0xffff888068bd4ffe
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea0001a152c8 ffff888098a3be48 ffff88809f983080
raw: ffff888068bd4ffe ffff888068bd4240 0000000100000002 ffff8880a1378580
page dumped because: kasan: bad access detected
page->mem_cgroup:ffff8880a1378580

Memory state around the buggy address:
 ffff888068bd4700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888068bd4780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888068bd4800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff888068bd4880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888068bd4900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (10):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-19 2020/01/26 12:00 linux-4.19.y d183c8e2647a f4e7270e .config log report syz C
ci2-linux-4-19 2020/04/11 01:14 linux-4.19.y dda0e2920330 a8c6a3f8 .config log report
ci2-linux-4-19 2020/03/03 10:01 linux-4.19.y a083db76118d 350a7a26 .config log report
ci2-linux-4-19 2020/02/14 06:07 linux-4.19.y 357668399cf7 5d7b90f1 .config log report
ci2-linux-4-19 2020/02/12 03:51 linux-4.19.y 357668399cf7 4d1ab643 .config log report
ci2-linux-4-19 2020/02/05 17:28 linux-4.19.y b499cf4b3a90 662cf49a .config log report
ci2-linux-4-19 2020/01/27 21:48 linux-4.19.y 88d6de67e390 56cd6c9b .config log report
ci2-linux-4-19 2020/01/26 07:51 linux-4.19.y d183c8e2647a f4e7270e .config log report
ci2-linux-4-19 2020/01/24 23:44 linux-4.19.y d183c8e2647a 2e95ab33 .config log report
ci2-linux-4-19 2019/12/23 13:44 linux-4.19.y 672481c2deff be5c2c81 .config log report