syzbot


KASAN: slab-use-after-free Read in update_io_ticks

Status: moderation: reported on 2024/09/02 03:24
Subsystems: block
[Documentation on labels]
Reported-by: syzbot+831de41ff5b97cc643aa@syzkaller.appspotmail.com
First crash: 39d, last: 39d

Sample crash report:
operation not supported error, dev loop0, sector 0 op 0x9:(WRITE_ZEROES) flags 0x10000800 phys_seg 0 prio class 0
==================================================================
BUG: KASAN: slab-use-after-free in update_io_ticks+0xa6/0x2d0 block/blk-core.c:996
Read of size 8 at addr ffff8880177c5c28 by task kworker/u4:0/11

CPU: 0 UID: 0 PID: 11 Comm: kworker/u4:0 Not tainted 6.11.0-rc5-syzkaller-00069-ga18093afa393 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: loop0 loop_rootcg_workfn
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:93 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 update_io_ticks+0xa6/0x2d0 block/blk-core.c:996
 blk_account_io_done+0x207/0x7d0 block/blk-mq.c:992
 __blk_mq_end_request_acct block/blk-mq.c:1031 [inline]
 __blk_mq_end_request+0x2bc/0x620 block/blk-mq.c:1037
 loop_handle_cmd drivers/block/loop.c:1927 [inline]
 loop_process_work+0x1c16/0x2180 drivers/block/loop.c:1945
 process_one_work kernel/workqueue.c:3231 [inline]
 process_scheduled_works+0xa2c/0x1830 kernel/workqueue.c:3312
 worker_thread+0x86d/0xd10 kernel/workqueue.c:3389
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>

Allocated by task 5111:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 unpoison_slab_object mm/kasan/common.c:312 [inline]
 __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:338
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3988 [inline]
 slab_alloc_node mm/slub.c:4037 [inline]
 kmem_cache_alloc_lru_noprof+0x139/0x2b0 mm/slub.c:4056
 bdev_alloc_inode+0x28/0x60 block/bdev.c:322
 alloc_inode fs/inode.c:263 [inline]
 new_inode_pseudo fs/inode.c:1073 [inline]
 new_inode+0x6e/0x310 fs/inode.c:1092
 bdev_alloc+0x26/0x380 block/bdev.c:413
 add_partition+0x1bb/0x890 block/partitions/core.c:321
 blk_add_partition block/partitions/core.c:556 [inline]
 blk_add_partitions block/partitions/core.c:623 [inline]
 bdev_disk_changed+0xb21/0x13d0 block/partitions/core.c:683
 loop_reread_partitions drivers/block/loop.c:534 [inline]
 loop_set_status+0x70d/0x900 drivers/block/loop.c:1303
 lo_ioctl+0xcc2/0x1f60
 blkdev_ioctl+0x580/0x6b0 block/ioctl.c:676
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:907 [inline]
 __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 16:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240
 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2252 [inline]
 slab_free mm/slub.c:4473 [inline]
 kmem_cache_free+0x145/0x350 mm/slub.c:4548
 rcu_do_batch kernel/rcu/tree.c:2569 [inline]
 rcu_core+0xafd/0x1830 kernel/rcu/tree.c:2843
 handle_softirqs+0x2c4/0x970 kernel/softirq.c:554
 run_ksoftirqd+0xca/0x130 kernel/softirq.c:928
 smpboot_thread_fn+0x544/0xa30 kernel/smpboot.c:164
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Last potentially related work creation:
 kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47
 __kasan_record_aux_stack+0xac/0xc0 mm/kasan/generic.c:541
 __call_rcu_common kernel/rcu/tree.c:3106 [inline]
 call_rcu+0x167/0xa70 kernel/rcu/tree.c:3210
 destroy_inode fs/inode.c:318 [inline]
 evict+0x88b/0x950 fs/inode.c:729
 device_release+0x99/0x1c0
 kobject_cleanup lib/kobject.c:689 [inline]
 kobject_release lib/kobject.c:720 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x22f/0x480 lib/kobject.c:737
 blkdev_release+0x15/0x20 block/fops.c:638
 __fput+0x24a/0x8a0 fs/file_table.c:422
 task_work_run+0x24f/0x310 kernel/task_work.c:228
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0x168/0x370 kernel/entry/common.c:218
 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff8880177c5c00
 which belongs to the cache bdev_cache of size 2784
The buggy address is located 40 bytes inside of
 freed 2784-byte region [ffff8880177c5c00, ffff8880177c66e0)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x177c0
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xfdffffff(slab)
raw: 00fff00000000040 ffff888016374280 dead000000000122 0000000000000000
raw: 0000000000000000 00000000800b000b 00000001fdffffff 0000000000000000
head: 00fff00000000040 ffff888016374280 dead000000000122 0000000000000000
head: 0000000000000000 00000000800b000b 00000001fdffffff 0000000000000000
head: 00fff00000000003 ffffea00005df001 ffffffffffffffff 0000000000000000
head: 0000000000000008 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Reclaimable, gfp_mask 0xd20d0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_RECLAIMABLE), pid 1, tgid 1 (swapper/0), ts 11775558956, free_ts 0
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1493
 prep_new_page mm/page_alloc.c:1501 [inline]
 get_page_from_freelist+0x2e4c/0x2f10 mm/page_alloc.c:3439
 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4695
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 alloc_slab_page+0x5f/0x120 mm/slub.c:2321
 allocate_slab+0x5a/0x2f0 mm/slub.c:2484
 new_slab mm/slub.c:2537 [inline]
 ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3723
 __slab_alloc+0x58/0xa0 mm/slub.c:3813
 __slab_alloc_node mm/slub.c:3866 [inline]
 slab_alloc_node mm/slub.c:4025 [inline]
 kmem_cache_alloc_lru_noprof+0x1c5/0x2b0 mm/slub.c:4056
 bdev_alloc_inode+0x28/0x60 block/bdev.c:322
 alloc_inode fs/inode.c:263 [inline]
 new_inode_pseudo fs/inode.c:1073 [inline]
 new_inode+0x6e/0x310 fs/inode.c:1092
 bdev_alloc+0x26/0x380 block/bdev.c:413
 __alloc_disk_node+0x12b/0x580 block/genhd.c:1356
 __blk_mq_alloc_disk+0x24b/0x3e0 block/blk-mq.c:4202
 nbd_dev_add+0x515/0xc70 drivers/block/nbd.c:1847
 nbd_init+0x210/0x2c0 drivers/block/nbd.c:2583
 do_one_initcall+0x248/0x880 init/main.c:1267
page_owner free stack trace missing

Memory state around the buggy address:
 ffff8880177c5b00: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
 ffff8880177c5b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880177c5c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                  ^
 ffff8880177c5c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880177c5d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/29 03:16 upstream a18093afa393 ef3de9e8 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-use-after-free Read in update_io_ticks
* Struck through repros no longer work on HEAD.