syzbot


KASAN: invalid-free in hfsplus_release_folio (2)

Status: upstream: reported on 2024/01/23 18:58
Subsystems: hfs
[Documentation on labels]
Reported-by: syzbot+4ab460b3092c782470be@syzkaller.appspotmail.com
First crash: 98d, last: 67d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [hfs?] KASAN: invalid-free in hfsplus_release_folio (2) 0 (1) 2024/01/23 18:58
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: invalid-free in hfsplus_release_folio hfs 5 297d 369d 0/26 auto-obsoleted due to no activity on 2023/10/13 01:48

Sample crash report:
==================================================================
BUG: KASAN: double-free in hfsplus_release_folio+0x51a/0x5f0 fs/hfsplus/inode.c:98
Free of addr ffff88801cef5ed0 by task kswapd0/109

CPU: 3 PID: 109 Comm: kswapd0 Not tainted 6.8.0-rc5-syzkaller #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:233 [inline]
 __kasan_slab_free+0x197/0x1c0 mm/kasan/common.c:257
 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
 hfsplus_release_folio+0x51a/0x5f0 fs/hfsplus/inode.c:98
 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+0x21d0/0x3790 mm/vmscan.c:5888
 kswapd_shrink_node mm/vmscan.c:6693 [inline]
 balance_pgdat+0x9d2/0x1a90 mm/vmscan.c:6883
 kswapd+0x5be/0xc00 mm/vmscan.c:7143
 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:242
 </TASK>

Allocated by task 9502:
 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:372 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:389
 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/0x870 fs/hfsplus/bnode.c:409
 hfsplus_bnode_find+0x2c8/0xcb0 fs/hfsplus/bnode.c:486
 hfsplus_brec_find+0x2b9/0x520 fs/hfsplus/bfind.c:183
 hfsplus_find_attr+0xe6/0x250 fs/hfsplus/attributes.c:153
 __hfsplus_getxattr+0x321/0x5f0 fs/hfsplus/xattr.c:522
 hfsplus_getxattr+0x91/0xe0 fs/hfsplus/xattr.c:590
 hfsplus_security_getxattr+0x39/0x50 fs/hfsplus/xattr_security.c:20
 vfs_getxattr_alloc+0x1b6/0x340 fs/xattr.c:394
 ima_read_xattr+0x38/0x60 security/integrity/ima/ima_appraise.c:231
 process_measurement+0xe18/0x2280 security/integrity/ima/ima_main.c:340
 ima_file_check+0xc2/0x110 security/integrity/ima/ima_main.c:557
 do_open fs/namei.c:3643 [inline]
 path_openat+0x17b1/0x29a0 fs/namei.c:3798
 do_filp_open+0x1de/0x440 fs/namei.c:3825
 do_sys_openat2+0x17a/0x1e0 fs/open.c:1404
 do_sys_open fs/open.c:1419 [inline]
 __do_compat_sys_openat fs/open.c:1479 [inline]
 __se_compat_sys_openat fs/open.c:1477 [inline]
 __ia32_compat_sys_openat+0x16e/0x210 fs/open.c:1477
 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+0x3f/0x60 mm/kasan/generic.c:640
 poison_slab_object mm/kasan/common.c:241 [inline]
 __kasan_slab_free+0x121/0x1c0 mm/kasan/common.c:257
 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
 hfsplus_btree_close+0xac/0x390 fs/hfsplus/btree.c:275
 hfsplus_put_super+0x224/0x3f0 fs/hfsplus/super.c:300
 generic_shutdown_super+0x159/0x3d0 fs/super.c:646
 kill_block_super+0x3b/0x90 fs/super.c:1680
 deactivate_locked_super+0xbe/0x1a0 fs/super.c:477
 deactivate_super+0xde/0x100 fs/super.c:510
 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+0x281/0x2b0 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 ffff88801cef5ed0
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 0 bytes inside of
 192-byte region [ffff88801cef5ed0, ffff88801cef5f90)

The buggy address belongs to the physical page:
page:ffffea000073bd00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1cef4
head:ffffea000073bd00 order:1 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888014c42a00 dead000000000100 dead000000000122
raw: 0000000000000000 00000000801e001e 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid 1 (swapper/0), ts 6871750310, free_ts 0
 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+0x22f/0x2440 mm/page_alloc.c:4567
 __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]
 kmalloc_trace+0x30b/0x340 mm/slub.c:4007
 kmalloc include/linux/slab.h:590 [inline]
 kzalloc include/linux/slab.h:711 [inline]
 call_usermodehelper_setup+0x9a/0x340 kernel/umh.c:363
 kobject_uevent_env+0xdbd/0x1600 lib/kobject_uevent.c:614
 tty_register_device_attr+0x4bc/0x7c0 drivers/tty/tty_io.c:3296
 tty_register_device drivers/tty/tty_io.c:3210 [inline]
 tty_register_driver+0x431/0x800 drivers/tty/tty_io.c:3473
 legacy_pty_init drivers/tty/pty.c:581 [inline]
 pty_init+0x69c/0x1110 drivers/tty/pty.c:943
 do_one_initcall+0x11c/0x5a0 init/main.c:1236
 do_initcall_level init/main.c:1298 [inline]
 do_initcalls init/main.c:1314 [inline]
 do_basic_setup init/main.c:1333 [inline]
 kernel_init_freeable+0x650/0xbc0 init/main.c:1551
 kernel_init+0x1c/0x2a0 init/main.c:1441
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
page_owner free stack trace missing

Memory state around the buggy address:
 ffff88801cef5d80: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
 ffff88801cef5e00: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
>ffff88801cef5e80: fc fc fc fc fc fc fc fc fc fc fa fb fb fb fb fb
                                                 ^
 ffff88801cef5f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88801cef5f80: fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/02/19 10:11 upstream b401b621758e 578f7538 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: invalid-free in hfsplus_release_folio
2024/01/19 18:53 upstream 9d1694dc91ce 9bd8dcda .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: invalid-free in hfsplus_release_folio
* Struck through repros no longer work on HEAD.