syzbot


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

Status: auto-obsoleted due to no activity on 2023/06/22 18:07
Subsystems: hfs
[Documentation on labels]
Reported-by: syzbot+2eac7d175baf21e6a5d5@syzkaller.appspotmail.com
First crash: 394d, last: 394d

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read include/linux/instrumented.h:72 [inline]
BUG: KASAN: slab-use-after-free in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
BUG: KASAN: slab-use-after-free in hfs_release_folio+0x40d/0x570 fs/hfs/inode.c:118
Read of size 4 at addr ffff88801b7f8b80 by task kswapd1/101

CPU: 2 PID: 101 Comm: kswapd1 Not tainted 6.3.0-rc3-syzkaller-00031-g1e760fa3596e #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:319
 print_report mm/kasan/report.c:430 [inline]
 kasan_report+0x11c/0x130 mm/kasan/report.c:536
 check_region_inline mm/kasan/generic.c:181 [inline]
 kasan_check_range+0x141/0x190 mm/kasan/generic.c:187
 instrument_atomic_read include/linux/instrumented.h:72 [inline]
 atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
 hfs_release_folio+0x40d/0x570 fs/hfs/inode.c:118
 filemap_release_folio+0x13f/0x1b0 mm/filemap.c:4121
 shrink_folio_list+0x1fe3/0x3c80 mm/vmscan.c:2010
 evict_folios+0x794/0x1940 mm/vmscan.c:5121
 try_to_shrink_lruvec+0x82c/0xb90 mm/vmscan.c:5297
 shrink_one+0x46b/0x810 mm/vmscan.c:5341
 shrink_many mm/vmscan.c:5394 [inline]
 lru_gen_shrink_node mm/vmscan.c:5511 [inline]
 shrink_node+0x2064/0x35f0 mm/vmscan.c:6459
 kswapd_shrink_node mm/vmscan.c:7262 [inline]
 balance_pgdat+0xa02/0x1ac0 mm/vmscan.c:7452
 kswapd+0x677/0xd60 mm/vmscan.c:7712
 kthread+0x2e8/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
 </TASK>

Allocated by task 7385:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 ____kasan_kmalloc mm/kasan/common.c:333 [inline]
 __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:383
 kasan_kmalloc include/linux/kasan.h:196 [inline]
 __do_kmalloc_node mm/slab_common.c:967 [inline]
 __kmalloc+0x5e/0x190 mm/slab_common.c:980
 kmalloc include/linux/slab.h:584 [inline]
 kzalloc include/linux/slab.h:720 [inline]
 __hfs_bnode_create+0x107/0x820 fs/hfs/bnode.c:259
 hfs_bnode_find+0x423/0xc60 fs/hfs/bnode.c:335
 hfs_bmap_alloc+0x102/0x800 fs/hfs/btree.c:266
 hfs_btree_inc_height.isra.0+0xe6/0x950 fs/hfs/brec.c:471
 hfs_brec_insert+0x983/0xbc0 fs/hfs/brec.c:77
 __hfs_ext_write_extent+0x3ec/0x510 fs/hfs/extent.c:124
 __hfs_ext_cache_extent fs/hfs/extent.c:174 [inline]
 hfs_ext_read_extent+0x81c/0xa20 fs/hfs/extent.c:202
 hfs_extend_file+0x4b5/0xae0 fs/hfs/extent.c:401
 hfs_get_block+0x17f/0x820 fs/hfs/extent.c:353
 __block_write_begin_int+0x3bd/0x14b0 fs/buffer.c:2034
 __block_write_begin fs/buffer.c:2084 [inline]
 block_write_begin+0xb9/0x4d0 fs/buffer.c:2145
 cont_write_begin+0x534/0x740 fs/buffer.c:2504
 hfs_write_begin+0x87/0x150 fs/hfs/inode.c:58
 generic_perform_write+0x256/0x570 mm/filemap.c:3926
 __generic_file_write_iter+0x2ae/0x500 mm/filemap.c:4054
 generic_file_write_iter+0xe3/0x350 mm/filemap.c:4086
 call_write_iter include/linux/fs.h:1851 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x9ed/0xe10 fs/read_write.c:584
 ksys_write+0x12b/0x250 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 5168:
 kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:521
 ____kasan_slab_free mm/kasan/common.c:236 [inline]
 ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200
 kasan_slab_free include/linux/kasan.h:162 [inline]
 __cache_free mm/slab.c:3390 [inline]
 __do_kmem_cache_free mm/slab.c:3577 [inline]
 __kmem_cache_free+0xcd/0x2c0 mm/slab.c:3584
 hfs_btree_close+0xab/0x390 fs/hfs/btree.c:154
 hfs_mdb_put+0x73/0x380 fs/hfs/mdb.c:359
 generic_shutdown_super+0x158/0x480 fs/super.c:500
 kill_block_super+0x9b/0xf0 fs/super.c:1407
 deactivate_locked_super+0x98/0x160 fs/super.c:331
 deactivate_super+0xb1/0xd0 fs/super.c:362
 cleanup_mnt+0x2ae/0x3d0 fs/namespace.c:1177
 task_work_run+0x16f/0x270 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
 exit_to_user_mode_prepare+0x23c/0x250 kernel/entry/common.c:203
 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
 syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296
 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88801b7f8b00
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 128 bytes inside of
 freed 192-byte region [ffff88801b7f8b00, ffff88801b7f8bc0)

The buggy address belongs to the physical page:
page:ffffea00006dfe00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88801b7f8e00 pfn:0x1b7f8
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffff888012440000 ffffea0000a40950 ffffea00006b5290
raw: ffff88801b7f8e00 ffff88801b7f8000 000000010000000f 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x2420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_THISNODE), pid 6114, tgid 6108 (syz-executor.2), ts 307238107354, free_ts 269932626213
 prep_new_page mm/page_alloc.c:2552 [inline]
 get_page_from_freelist+0x1190/0x2e20 mm/page_alloc.c:4325
 __alloc_pages_slowpath.constprop.0+0x2e7/0x2170 mm/page_alloc.c:5125
 __alloc_pages+0x408/0x4a0 mm/page_alloc.c:5604
 __alloc_pages_node include/linux/gfp.h:237 [inline]
 kmem_getpages mm/slab.c:1360 [inline]
 cache_grow_begin+0x9b/0x3b0 mm/slab.c:2570
 cache_alloc_refill+0x27f/0x380 mm/slab.c:2943
 ____cache_alloc mm/slab.c:3019 [inline]
 ____cache_alloc mm/slab.c:3002 [inline]
 __do_cache_alloc mm/slab.c:3202 [inline]
 slab_alloc_node mm/slab.c:3250 [inline]
 __kmem_cache_alloc_node+0x360/0x3f0 mm/slab.c:3541
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1061
 kmalloc include/linux/slab.h:580 [inline]
 kzalloc include/linux/slab.h:720 [inline]
 push_stack+0x77/0x560 kernel/bpf/verifier.c:1495
 check_cond_jmp_op kernel/bpf/verifier.c:12512 [inline]
 do_check kernel/bpf/verifier.c:14829 [inline]
 do_check_common+0x601e/0xbd20 kernel/bpf/verifier.c:17089
 do_check_main kernel/bpf/verifier.c:17152 [inline]
 bpf_check+0x67eb/0xb190 kernel/bpf/verifier.c:17759
 bpf_prog_load+0x16d9/0x21c0 kernel/bpf/syscall.c:2632
 __sys_bpf+0x1435/0x5100 kernel/bpf/syscall.c:4992
 __do_sys_bpf kernel/bpf/syscall.c:5096 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5094 [inline]
 __x64_sys_bpf+0x79/0xc0 kernel/bpf/syscall.c:5094
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1453 [inline]
 free_pcp_prepare+0x5d5/0xa50 mm/page_alloc.c:1503
 free_unref_page_prepare mm/page_alloc.c:3387 [inline]
 free_unref_page+0x1d/0x490 mm/page_alloc.c:3482
 slab_destroy mm/slab.c:1613 [inline]
 slabs_destroy+0x85/0xc0 mm/slab.c:1633
 cache_flusharray mm/slab.c:3361 [inline]
 ___cache_free+0x2ae/0x3d0 mm/slab.c:3424
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x4f/0x1a0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x192/0x220 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x63/0x90 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:186 [inline]
 slab_post_alloc_hook mm/slab.h:769 [inline]
 slab_alloc_node mm/slab.c:3257 [inline]
 __kmem_cache_alloc_node+0x1fc/0x3f0 mm/slab.c:3541
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1061
 kmalloc include/linux/slab.h:580 [inline]
 kzalloc include/linux/slab.h:720 [inline]
 kobject_uevent_env+0x232/0x16c0 lib/kobject_uevent.c:524
 __kobject_del+0x160/0x1f0 lib/kobject.c:593
 kobject_cleanup lib/kobject.c:672 [inline]
 kobject_release lib/kobject.c:712 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x2f1/0x4d0 lib/kobject.c:729
 netdev_queue_update_kobjects+0x36b/0x4f0 net/core/net-sysfs.c:1761
 netif_set_real_num_tx_queues+0x1ba/0x870 net/core/dev.c:2879
 veth_init_queues+0xdd/0x190 drivers/net/veth.c:1757
 veth_newlink+0x540/0x9d0 drivers/net/veth.c:1877

Memory state around the buggy address:
 ffff88801b7f8a80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88801b7f8b00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88801b7f8b80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                   ^
 ffff88801b7f8c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88801b7f8c80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/03/24 18:07 upstream 1e760fa3596e ee89d73c .config console log report info ci-qemu-upstream KASAN: slab-use-after-free Read in hfs_release_folio
* Struck through repros no longer work on HEAD.