syzbot


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

Status: moderation: reported on 2025/01/01 07:02
Subsystems: exfat
[Documentation on labels]
Reported-by: syzbot+689fad2882e6eeb29091@syzkaller.appspotmail.com
First crash: 7d16h, last: 7d16h
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 general protection fault in __find_get_block (2) 1 1148d 1148d 0/1 auto-closed as invalid on 2022/03/13 03:33

Sample crash report:
loop0: detected capacity change from 0 to 256
=======================================================
WARNING: The mand mount option has been deprecated and
         and is ignored by this kernel. Remove the mand
         option from the mount to silence this warning.
=======================================================
exfat: Deprecated parameter 'namecase'
exFAT-fs (loop0): failed to load upcase table (idx : 0x00010000, chksum : 0x1cbb3694, utbl_chksum : 0xe619d30d)
exFAT-fs (loop0): error, in sector 160, dentry 5 should be unused, but 0xc1
==================================================================
BUG: KASAN: slab-use-after-free in lookup_bh_lru fs/buffer.c:1367 [inline]
BUG: KASAN: slab-use-after-free in __find_get_block+0x4af/0x1150 fs/buffer.c:1394
Read of size 8 at addr ffff888012c451e8 by task syz.0.0/5316

CPU: 0 UID: 0 PID: 5316 Comm: syz.0.0 Not tainted 6.13.0-rc4-syzkaller-00069-g8379578b11d5 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:489
 kasan_report+0x143/0x180 mm/kasan/report.c:602
 lookup_bh_lru fs/buffer.c:1367 [inline]
 __find_get_block+0x4af/0x1150 fs/buffer.c:1394
 sb_find_get_block include/linux/buffer_head.h:398 [inline]
 exfat_dir_readahead fs/exfat/dir.c:642 [inline]
 exfat_get_dentry+0x369/0x730 fs/exfat/dir.c:670
 exfat_find_dir_entry+0x56a/0x29c0 fs/exfat/dir.c:1028
 exfat_find fs/exfat/namei.c:629 [inline]
 exfat_lookup+0x810/0x1e70 fs/exfat/namei.c:727
 lookup_open fs/namei.c:3627 [inline]
 open_last_lookups fs/namei.c:3748 [inline]
 path_openat+0x11a7/0x3590 fs/namei.c:3984
 do_filp_open+0x27f/0x4e0 fs/namei.c:4014
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1402
 do_sys_open fs/open.c:1417 [inline]
 __do_sys_openat fs/open.c:1433 [inline]
 __se_sys_openat fs/open.c:1428 [inline]
 __x64_sys_openat+0x247/0x2a0 fs/open.c:1428
 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
RIP: 0033:0x7f2064f85d29
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f20649fe038 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f2065175fa0 RCX: 00007f2064f85d29
RDX: 0000000000105042 RSI: 0000000020000080 RDI: ffffffffffffff9c
RBP: 00007f2065001b08 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000000001db R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f2065175fa0 R15: 00007fff73a00208
 </TASK>

Allocated by task 5316:
 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:319 [inline]
 __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:345
 kasan_slab_alloc include/linux/kasan.h:250 [inline]
 slab_post_alloc_hook mm/slub.c:4119 [inline]
 slab_alloc_node mm/slub.c:4168 [inline]
 kmem_cache_alloc_noprof+0x1d9/0x380 mm/slub.c:4175
 alloc_buffer_head+0x2a/0x290 fs/buffer.c:3015
 folio_alloc_buffers+0x31f/0x640 fs/buffer.c:924
 grow_dev_folio fs/buffer.c:1064 [inline]
 grow_buffers fs/buffer.c:1105 [inline]
 __getblk_slow fs/buffer.c:1131 [inline]
 bdev_getblk+0x2af/0x670 fs/buffer.c:1431
 __breadahead+0x2b/0x240 fs/buffer.c:1440
 sb_breadahead include/linux/buffer_head.h:358 [inline]
 exfat_dir_readahead fs/exfat/dir.c:647 [inline]
 exfat_get_dentry+0x464/0x730 fs/exfat/dir.c:670
 exfat_create_upcase_table+0x242/0xf60 fs/exfat/nls.c:758
 __exfat_fill_super fs/exfat/super.c:628 [inline]
 exfat_fill_super+0x1196/0x2920 fs/exfat/super.c:678
 get_tree_bdev_flags+0x48c/0x5c0 fs/super.c:1636
 vfs_get_tree+0x90/0x2b0 fs/super.c:1814
 do_new_mount+0x2be/0xb40 fs/namespace.c:3507
 do_mount fs/namespace.c:3847 [inline]
 __do_sys_mount fs/namespace.c:4057 [inline]
 __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4034
 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 5316:
 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:582
 poison_slab_object mm/kasan/common.c:247 [inline]
 __kasan_slab_free+0x59/0x70 mm/kasan/common.c:264
 kasan_slab_free include/linux/kasan.h:233 [inline]
 slab_free_hook mm/slub.c:2353 [inline]
 slab_free mm/slub.c:4613 [inline]
 kmem_cache_free+0x195/0x410 mm/slub.c:4715
 free_buffer_head+0x54/0x240 fs/buffer.c:3031
 try_to_free_buffers+0x2fa/0x3b0 fs/buffer.c:2972
 shrink_folio_list+0x241e/0x5ca0 mm/vmscan.c:1433
 evict_folios+0x3c86/0x5800 mm/vmscan.c:4593
 try_to_shrink_lruvec+0x9a6/0xc70 mm/vmscan.c:4789
 shrink_one+0x3b9/0x850 mm/vmscan.c:4834
 shrink_many mm/vmscan.c:4897 [inline]
 lru_gen_shrink_node mm/vmscan.c:4975 [inline]
 shrink_node+0x37c5/0x3e50 mm/vmscan.c:5956
 shrink_zones mm/vmscan.c:6215 [inline]
 do_try_to_free_pages+0x78c/0x1cf0 mm/vmscan.c:6277
 try_to_free_pages+0x47c/0x1050 mm/vmscan.c:6527
 __perform_reclaim mm/page_alloc.c:3929 [inline]
 __alloc_pages_direct_reclaim+0x178/0x3c0 mm/page_alloc.c:3951
 __alloc_pages_slowpath+0x764/0x1020 mm/page_alloc.c:4382
 __alloc_pages_noprof+0x49b/0x710 mm/page_alloc.c:4766
 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2269
 folio_alloc_mpol_noprof+0x36/0x50 mm/mempolicy.c:2287
 shmem_alloc_folio mm/shmem.c:1798 [inline]
 shmem_alloc_and_add_folio+0x4a0/0x1080 mm/shmem.c:1837
 shmem_get_folio_gfp+0x621/0x1840 mm/shmem.c:2357
 shmem_get_folio mm/shmem.c:2463 [inline]
 shmem_write_begin+0x165/0x350 mm/shmem.c:3119
 generic_perform_write+0x346/0x990 mm/filemap.c:4055
 shmem_file_write_iter+0xf9/0x120 mm/shmem.c:3295
 new_sync_write fs/read_write.c:586 [inline]
 vfs_write+0xaeb/0xd30 fs/read_write.c:679
 ksys_write+0x18f/0x2b0 fs/read_write.c:731
 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

The buggy address belongs to the object at ffff888012c451d0
 which belongs to the cache buffer_head of size 168
The buggy address is located 24 bytes inside of
 freed 168-byte region [ffff888012c451d0, ffff888012c45278)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x12c45
memcg:ffff888000223a01
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000000 ffff88801c2eadc0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000110011 00000001f5000000 ffff888000223a01
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Reclaimable, gfp_mask 0x52810(GFP_NOWAIT|__GFP_NORETRY|__GFP_COMP|__GFP_RECLAIMABLE), pid 5316, tgid 5315 (syz.0.0), ts 69189616209, free_ts 41366811191
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1558
 prep_new_page mm/page_alloc.c:1566 [inline]
 get_page_from_freelist+0x365c/0x37a0 mm/page_alloc.c:3476
 __alloc_pages_slowpath+0x414/0x1020 mm/page_alloc.c:4288
 __alloc_pages_noprof+0x49b/0x710 mm/page_alloc.c:4766
 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2269
 alloc_slab_page+0x6a/0x110 mm/slub.c:2423
 allocate_slab+0x5a/0x2b0 mm/slub.c:2589
 new_slab mm/slub.c:2642 [inline]
 ___slab_alloc+0xc27/0x14a0 mm/slub.c:3830
 __slab_alloc+0x58/0xa0 mm/slub.c:3920
 __slab_alloc_node mm/slub.c:3995 [inline]
 slab_alloc_node mm/slub.c:4156 [inline]
 kmem_cache_alloc_noprof+0x268/0x380 mm/slub.c:4175
 alloc_buffer_head+0x2a/0x290 fs/buffer.c:3015
 folio_alloc_buffers+0x31f/0x640 fs/buffer.c:924
 grow_dev_folio fs/buffer.c:1064 [inline]
 grow_buffers fs/buffer.c:1105 [inline]
 __getblk_slow fs/buffer.c:1131 [inline]
 bdev_getblk+0x2af/0x670 fs/buffer.c:1431
 __breadahead+0x2b/0x240 fs/buffer.c:1440
 sb_breadahead include/linux/buffer_head.h:358 [inline]
 exfat_dir_readahead fs/exfat/dir.c:647 [inline]
 exfat_get_dentry+0x464/0x730 fs/exfat/dir.c:670
 exfat_create_upcase_table+0x242/0xf60 fs/exfat/nls.c:758
page last free pid 8 tgid 8 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1127 [inline]
 free_unref_page+0xd3f/0x1010 mm/page_alloc.c:2659
 vfree+0x1c3/0x360 mm/vmalloc.c:3383
 delayed_vfree_work+0x56/0x80 mm/vmalloc.c:3303
 process_one_work kernel/workqueue.c:3229 [inline]
 process_scheduled_works+0xa66/0x1840 kernel/workqueue.c:3310
 worker_thread+0x870/0xd30 kernel/workqueue.c:3391
 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

Memory state around the buggy address:
 ffff888012c45080: fb fb fb fb fb fc fc fc fc fc fc fc fc fa fb fb
 ffff888012c45100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888012c45180: fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb
                                                          ^
 ffff888012c45200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc
 ffff888012c45280: fc fc fc fc fc fc fc fa 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/12/28 06:58 upstream 8379578b11d5 d3ccff63 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-use-after-free Read in __find_get_block
* Struck through repros no longer work on HEAD.