syzbot


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

Status: moderation: reported on 2025/01/03 03:13
Subsystems: exfat
[Documentation on labels]
Reported-by: syzbot+762aa8bd96a906a0d570@syzkaller.appspotmail.com
First crash: 6d04h, last: 6d04h
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream BUG: unable to handle kernel paging request in __brelse udf C error 383 191d 193d 0/28 auto-obsoleted due to no activity on 2024/08/06 14:25

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
syz.0.0: attempt to access beyond end of device
loop0: rw=2049, sector=225, nr_sectors = 1 limit=0
Buffer I/O error on dev loop0, logical block 225, lost async page write
syz.0.0: attempt to access beyond end of device
loop0: rw=2049, sector=226, nr_sectors = 1 limit=0
Buffer I/O error on dev loop0, logical block 226, lost async page write
syz.0.0: attempt to access beyond end of device
loop0: rw=2049, sector=227, nr_sectors = 1 limit=0
Buffer I/O error on dev loop0, logical block 227, lost async page write
syz.0.0: attempt to access beyond end of device
loop0: rw=2049, sector=228, nr_sectors = 1 limit=0
Buffer I/O error on dev loop0, logical block 228, lost async page write
syz.0.0: attempt to access beyond end of device
loop0: rw=2049, sector=229, nr_sectors = 1 limit=0
Buffer I/O error on dev loop0, logical block 229, lost async page write
syz.0.0: attempt to access beyond end of device
loop0: rw=2049, sector=230, nr_sectors = 1 limit=0
Buffer I/O error on dev loop0, logical block 230, lost async page write
syz.0.0: attempt to access beyond end of device
loop0: rw=2049, sector=231, nr_sectors = 1 limit=0
Buffer I/O error on dev loop0, logical block 231, lost async page write
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read include/linux/instrumented.h:68 [inline]
BUG: KASAN: slab-use-after-free in atomic_read include/linux/atomic/atomic-instrumented.h:32 [inline]
BUG: KASAN: slab-use-after-free in __brelse+0x1f/0xa0 fs/buffer.c:1225
Read of size 4 at addr ffff888043ee6148 by task syz.0.0/5315

CPU: 0 UID: 0 PID: 5315 Comm: syz.0.0 Not tainted 6.13.0-rc4-syzkaller-00110-g4099a71718b0 #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
 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189
 instrument_atomic_read include/linux/instrumented.h:68 [inline]
 atomic_read include/linux/atomic/atomic-instrumented.h:32 [inline]
 __brelse+0x1f/0xa0 fs/buffer.c:1225
 brelse include/linux/buffer_head.h:324 [inline]
 exfat_put_dentry_set+0x182/0x2b0 fs/exfat/dir.c:553
 exfat_add_entry+0x6ff/0xaa0 fs/exfat/namei.c:505
 exfat_mkdir+0x1c7/0x580 fs/exfat/namei.c:858
 vfs_mkdir+0x2f9/0x4f0 fs/namei.c:4311
 do_mkdirat+0x264/0x3a0 fs/namei.c:4334
 __do_sys_mkdirat fs/namei.c:4349 [inline]
 __se_sys_mkdirat fs/namei.c:4347 [inline]
 __x64_sys_mkdirat+0x87/0xa0 fs/namei.c:4347
 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:0x7fabf4785d29
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:00007fabf55f0038 EFLAGS: 00000246 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007fabf4975fa0 RCX: 00007fabf4785d29
RDX: 0000000000000000 RSI: 0000000020000080 RDI: ffffffffffffff9c
RBP: 00007fabf4801b08 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fabf4975fa0 R15: 00007ffd77baaa48
 </TASK>

Allocated by task 5315:
 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 5317:
 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
 mapping_evict_folio+0x242/0x300 mm/truncate.c:258
 mapping_try_invalidate+0x24a/0x550 mm/truncate.c:482
 loop_set_status+0x1ab/0x8f0 drivers/block/loop.c:1263
 lo_ioctl+0xcbc/0x1f50
 blkdev_ioctl+0x57d/0x6a0 block/ioctl.c:693
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:906 [inline]
 __se_sys_ioctl+0xf5/0x170 fs/ioctl.c:892
 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 ffff888043ee60e8
 which belongs to the cache buffer_head of size 168
The buggy address is located 96 bytes inside of
 freed 168-byte region [ffff888043ee60e8, ffff888043ee6190)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x43ee6
memcg:ffff888033d8ad01
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 04fff00000000000 ffff88801c2e6dc0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000110011 00000001f5000000 ffff888033d8ad01
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 5315, tgid 5314 (syz.0.0), ts 69151654138, free_ts 0
 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_noprof+0x292/0x710 mm/page_alloc.c:4753
 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
 __exfat_fill_super fs/exfat/super.c:628 [inline]
 exfat_fill_super+0x1196/0x2920 fs/exfat/super.c:678
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888043ee6000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888043ee6080: fb fb fb fb fb fc fc fc fc fc fc fc fc fa fb fb
>ffff888043ee6100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff888043ee6180: fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb
 ffff888043ee6200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc
==================================================================

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