syzbot


KASAN: invalid-free in hfs_release_folio (2)

Status: upstream: reported on 2024/02/05 09:01
Subsystems: hfs
[Documentation on labels]
Reported-by: syzbot+be88fd56f9769df61aee@syzkaller.appspotmail.com
First crash: 76d, last: 42d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [hfs?] KASAN: invalid-free in hfs_release_folio (2) 0 (1) 2024/02/05 09:01
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: invalid-free in hfs_release_folio hfs 13 239d 414d 0/26 auto-obsoleted due to no activity on 2023/12/04 08:11

Sample crash report:
==================================================================
BUG: KASAN: double-free in hfs_release_folio+0x435/0x570 fs/hfs/inode.c:118
Free of addr ffff88804a187d00 by task kswapd0/110

CPU: 3 PID: 110 Comm: kswapd0 Not tainted 6.8.0-rc7-syzkaller-00231-g09e5c48fea17 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc4/0x620 mm/kasan/report.c:488
 kasan_report_invalid_free+0xab/0xd0 mm/kasan/report.c:563
 poison_slab_object mm/kasan/common.c:232 [inline]
 __kasan_slab_free+0x16b/0x1a0 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2121 [inline]
 slab_free mm/slub.c:4299 [inline]
 kfree+0x124/0x370 mm/slub.c:4409
 hfs_release_folio+0x435/0x570 fs/hfs/inode.c:118
 filemap_release_folio+0x1f1/0x280 mm/filemap.c:4088
 shrink_folio_list+0x2933/0x3ea0 mm/vmscan.c:1369
 evict_folios+0x6e7/0x1b90 mm/vmscan.c:4521
 try_to_shrink_lruvec+0x638/0xa10 mm/vmscan.c:4726
 shrink_one+0x3f8/0x7b0 mm/vmscan.c:4765
 shrink_many mm/vmscan.c:4828 [inline]
 lru_gen_shrink_node mm/vmscan.c:4929 [inline]
 shrink_node+0x21c0/0x37a0 mm/vmscan.c:5888
 kswapd_shrink_node mm/vmscan.c:6696 [inline]
 balance_pgdat+0x9d2/0x1a90 mm/vmscan.c:6886
 kswapd+0x5be/0xc00 mm/vmscan.c:7146
 kthread+0x2c6/0x3b0 kernel/kthread.c:388
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:243
 </TASK>

Allocated by task 7994:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:387
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slub.c:3981 [inline]
 __kmalloc+0x1f9/0x440 mm/slub.c:3994
 kmalloc include/linux/slab.h:594 [inline]
 kzalloc include/linux/slab.h:711 [inline]
 __hfs_bnode_create+0x108/0x860 fs/hfs/bnode.c:259
 hfs_bnode_find+0x2d1/0xc50 fs/hfs/bnode.c:335
 hfs_bmap_alloc+0x10e/0x880 fs/hfs/btree.c:266
 hfs_btree_inc_height.isra.0+0x100/0x830 fs/hfs/brec.c:471
 hfs_brec_insert+0x938/0xb90 fs/hfs/brec.c:77
 __hfs_ext_write_extent+0x3fa/0x520 fs/hfs/extent.c:124
 __hfs_ext_cache_extent fs/hfs/extent.c:174 [inline]
 hfs_ext_read_extent+0x809/0x9e0 fs/hfs/extent.c:202
 hfs_extend_file+0x4e4/0xb10 fs/hfs/extent.c:401
 hfs_get_block+0x17f/0x830 fs/hfs/extent.c:353
 __block_write_begin_int+0x4fb/0x16e0 fs/buffer.c:2103
 __block_write_begin fs/buffer.c:2152 [inline]
 block_write_begin+0xb1/0x4a0 fs/buffer.c:2211
 cont_write_begin+0x53e/0x750 fs/buffer.c:2565
 hfs_write_begin+0x87/0x150 fs/hfs/inode.c:53
 generic_perform_write+0x273/0x620 mm/filemap.c:3930
 __generic_file_write_iter+0x1fd/0x240 mm/filemap.c:4025
 generic_file_write_iter+0xe7/0x350 mm/filemap.c:4051
 call_write_iter include/linux/fs.h:2087 [inline]
 new_sync_write fs/read_write.c:497 [inline]
 vfs_write+0x6de/0x1110 fs/read_write.c:590
 ksys_write+0x12f/0x260 fs/read_write.c:643
 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
 __do_fast_syscall_32+0x7c/0x120 arch/x86/entry/common.c:321
 do_fast_syscall_32+0x33/0x80 arch/x86/entry/common.c:346
 entry_SYSENTER_compat_after_hwframe+0x7c/0x86

Freed by task 5211:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:589
 poison_slab_object mm/kasan/common.c:240 [inline]
 __kasan_slab_free+0x11d/0x1a0 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2121 [inline]
 slab_free mm/slub.c:4299 [inline]
 kfree+0x124/0x370 mm/slub.c:4409
 hfs_btree_close+0xac/0x390 fs/hfs/btree.c:154
 hfs_mdb_put+0x73/0x380 fs/hfs/mdb.c:359
 generic_shutdown_super+0x159/0x3d0 fs/super.c:641
 kill_block_super+0x3b/0x90 fs/super.c:1675
 deactivate_locked_super+0xbe/0x1a0 fs/super.c:472
 deactivate_super+0xde/0x100 fs/super.c:505
 cleanup_mnt+0x222/0x450 fs/namespace.c:1267
 task_work_run+0x14f/0x250 kernel/task_work.c:180
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:108 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:201 [inline]
 syscall_exit_to_user_mode+0x278/0x2a0 kernel/entry/common.c:212
 __do_fast_syscall_32+0x8c/0x120 arch/x86/entry/common.c:324
 do_fast_syscall_32+0x33/0x80 arch/x86/entry/common.c:346
 entry_SYSENTER_compat_after_hwframe+0x7c/0x86

The buggy address belongs to the object at ffff88804a187d00
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 0 bytes inside of
 192-byte region [ffff88804a187d00, ffff88804a187dc0)

The buggy address belongs to the physical page:
page:ffffea00012861c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4a187
flags: 0x4fff00000000800(slab|node=1|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 04fff00000000800 ffff888014c42a00 dead000000000100 dead000000000122
raw: 0000000000000000 0000000080100010 00000001ffffffff 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 5583, tgid 5583 (syz-executor.3), ts 182695198523, free_ts 181817486927
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x2d4/0x350 mm/page_alloc.c:1533
 prep_new_page mm/page_alloc.c:1540 [inline]
 get_page_from_freelist+0xa28/0x3780 mm/page_alloc.c:3311
 __alloc_pages+0x22c/0x2430 mm/page_alloc.c:4569
 __alloc_pages_node include/linux/gfp.h:238 [inline]
 alloc_pages_node include/linux/gfp.h:261 [inline]
 alloc_slab_page mm/slub.c:2190 [inline]
 allocate_slab mm/slub.c:2354 [inline]
 new_slab+0xcc/0x3a0 mm/slub.c:2407
 ___slab_alloc+0x4b0/0x1780 mm/slub.c:3540
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3625
 __slab_alloc_node mm/slub.c:3678 [inline]
 slab_alloc_node mm/slub.c:3850 [inline]
 __do_kmalloc_node mm/slub.c:3980 [inline]
 __kmalloc_node+0x361/0x470 mm/slub.c:3988
 kmalloc_array_node include/linux/slab.h:688 [inline]
 kcalloc_node include/linux/slab.h:693 [inline]
 memcg_alloc_slab_cgroups+0xa9/0x180 mm/memcontrol.c:3014
 __memcg_slab_post_alloc_hook+0xa3/0x370 mm/slub.c:1970
 memcg_slab_post_alloc_hook mm/slub.c:1993 [inline]
 slab_post_alloc_hook mm/slub.c:3822 [inline]
 slab_alloc_node mm/slub.c:3860 [inline]
 kmem_cache_alloc_lru+0x39b/0x700 mm/slub.c:3879
 __d_alloc+0x35/0x8c0 fs/dcache.c:1624
 d_alloc+0x4a/0x1e0 fs/dcache.c:1704
 d_alloc_parallel+0xe9/0x12c0 fs/dcache.c:2462
 __lookup_slow+0x194/0x460 fs/namei.c:1678
 lookup_slow fs/namei.c:1710 [inline]
 walk_component+0x350/0x5b0 fs/namei.c:2005
 lookup_last fs/namei.c:2462 [inline]
 path_lookupat+0x17f/0x770 fs/namei.c:2486
page last free pid 5466 tgid 5466 stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1140 [inline]
 free_unref_page_prepare+0x527/0xb10 mm/page_alloc.c:2346
 free_unref_page+0x33/0x3c0 mm/page_alloc.c:2486
 __put_partials+0x14c/0x170 mm/slub.c:2922
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x4e/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x192/0x1e0 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:322
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3813 [inline]
 slab_alloc_node mm/slub.c:3860 [inline]
 kmem_cache_alloc+0x136/0x320 mm/slub.c:3867
 kmem_cache_zalloc include/linux/slab.h:701 [inline]
 jbd2_alloc_handle include/linux/jbd2.h:1591 [inline]
 new_handle fs/jbd2/transaction.c:476 [inline]
 jbd2__journal_start+0x194/0x850 fs/jbd2/transaction.c:503
 __ext4_journal_start_sb+0x347/0x5e0 fs/ext4/ext4_jbd2.c:112
 __ext4_journal_start fs/ext4/ext4_jbd2.h:326 [inline]
 ext4_dirty_inode+0xa1/0x130 fs/ext4/inode.c:5939
 __mark_inode_dirty+0x1e0/0xd60 fs/fs-writeback.c:2452
 generic_update_time+0xcf/0xf0 fs/inode.c:1905
 inode_update_time fs/inode.c:1918 [inline]
 __file_update_time fs/inode.c:2106 [inline]
 file_modified_flags fs/inode.c:2177 [inline]
 file_modified+0x1c8/0x200 fs/inode.c:2193
 ext4_write_checks fs/ext4/file.c:279 [inline]
 ext4_buffered_write_iter+0xf9/0x3d0 fs/ext4/file.c:295
 ext4_file_write_iter+0x819/0x1960 fs/ext4/file.c:698
 __kernel_write_iter+0x33e/0xa70 fs/read_write.c:523

Memory state around the buggy address:
 ffff88804a187c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88804a187c80: 04 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88804a187d00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88804a187d80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88804a187e00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/03/09 20:29 upstream 09e5c48fea17 6ee49f2e .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: invalid-free in hfs_release_folio
2024/02/26 02:10 upstream 70ff1fe626a1 8d446f15 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: invalid-free in hfs_release_folio
2024/02/05 06:57 upstream 54be6c6c5ae8 a67b2c42 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: invalid-free in hfs_release_folio
* Struck through repros no longer work on HEAD.