syzbot


KASAN: use-after-free Read in xfs_buf_rele

Status: upstream: reported syz repro on 2022/12/14 21:15
Reported-by: syzbot+ec97370b548269aab5ab@syzkaller.appspotmail.com
First crash: 737d, last: 656d
Fix bisection: failed (error log, bisect log)
  
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in xfs_buf_rele xfs C 1 658d 728d 0/1 upstream: reported C repro on 2022/12/24 01:04
upstream KASAN: slab-use-after-free Read in xfs_buf_rele xfs 2 190d 217d 0/28 auto-obsoleted due to no activity on 2024/09/11 19:16
upstream KASAN: slab-use-after-free Read in xfs_buf_rele (2) xfs 1 22d 12d 0/28 upstream: reported on 2024/12/09 11:23

Sample crash report:
syz-executor.0 (6378): drop_caches: 2
XFS (loop3): Ending clean mount
syz-executor.0 (6378): drop_caches: 2
XFS (loop0): Unmounting Filesystem
==================================================================
BUG: KASAN: use-after-free in rht_key_hashfn include/linux/rhashtable.h:132 [inline]
BUG: KASAN: use-after-free in rht_head_hashfn include/linux/rhashtable.h:147 [inline]
BUG: KASAN: use-after-free in __rhashtable_remove_fast_one include/linux/rhashtable.h:882 [inline]
BUG: KASAN: use-after-free in __rhashtable_remove_fast include/linux/rhashtable.h:962 [inline]
BUG: KASAN: use-after-free in rhashtable_remove_fast include/linux/rhashtable.h:991 [inline]
BUG: KASAN: use-after-free in xfs_buf_rele+0x147b/0x1540 fs/xfs/xfs_buf.c:1086
Read of size 4 at addr ffff888099771c8c by task syz-executor.3/6384

CPU: 1 PID: 6384 Comm: syz-executor.3 Not tainted 4.19.211-syzkaller #0
XFS (loop5): Mounting V4 Filesystem
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
XFS (loop5): Ending clean mount
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_load4_noabort+0x88/0x90 mm/kasan/report.c:432
 rht_key_hashfn include/linux/rhashtable.h:132 [inline]
 rht_head_hashfn include/linux/rhashtable.h:147 [inline]
 __rhashtable_remove_fast_one include/linux/rhashtable.h:882 [inline]
 __rhashtable_remove_fast include/linux/rhashtable.h:962 [inline]
 rhashtable_remove_fast include/linux/rhashtable.h:991 [inline]
 xfs_buf_rele+0x147b/0x1540 fs/xfs/xfs_buf.c:1086
 xfs_buftarg_shrink_scan+0x1bc/0x2c0 fs/xfs/xfs_buf.c:1753
 do_shrink_slab+0x397/0xa40 mm/vmscan.c:537
 shrink_slab+0x16f/0x550 mm/vmscan.c:693
syz-executor.5 (6389): drop_caches: 2
 drop_slab_node+0x33/0x70 mm/vmscan.c:724
 drop_slab+0x4b/0x90 mm/vmscan.c:734
syz-executor.5 (6389): drop_caches: 2
 drop_caches_sysctl_handler+0xf6/0x110 fs/drop_caches.c:65
 proc_sys_call_handler.isra.0+0x1f3/0x3b0 fs/proc/proc_sysctl.c:597
 __vfs_write+0xf7/0x770 fs/read_write.c:485
 __kernel_write+0x109/0x370 fs/read_write.c:506
 write_pipe_buf+0x153/0x1f0 fs/splice.c:798
 splice_from_pipe_feed fs/splice.c:503 [inline]
 __splice_from_pipe+0x389/0x800 fs/splice.c:627
 splice_from_pipe fs/splice.c:662 [inline]
 default_file_splice_write+0xd8/0x180 fs/splice.c:810
 do_splice_from fs/splice.c:852 [inline]
 direct_splice_actor+0x115/0x160 fs/splice.c:1025
 splice_direct_to_actor+0x33f/0x8d0 fs/splice.c:980
 do_splice_direct+0x1a7/0x270 fs/splice.c:1068
 do_sendfile+0x550/0xc30 fs/read_write.c:1447
 __do_sys_sendfile64 fs/read_write.c:1502 [inline]
 __se_sys_sendfile64+0xc4/0x160 fs/read_write.c:1494
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f7af1baa0f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f7af0f1c168 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 00007f7af1cc9f80 RCX: 00007f7af1baa0f9
RDX: 0000000020002080 RSI: 0000000000000006 RDI: 0000000000000007
RBP: 00007f7af1c05ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000870 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fff170e9c5f R14: 00007f7af0f1c300 R15: 0000000000022000

Allocated by task 6378:
 __do_kmalloc_node mm/slab.c:3689 [inline]
 __kmalloc_node+0x4c/0x70 mm/slab.c:3696
 kmalloc_node include/linux/slab.h:557 [inline]
 kvmalloc_node+0x61/0xf0 mm/util.c:423
 kvmalloc include/linux/mm.h:577 [inline]
 kvzalloc include/linux/mm.h:585 [inline]
 bucket_table_alloc+0x3a/0x440 lib/rhashtable.c:176
 rhashtable_init+0x3bc/0x810 lib/rhashtable.c:1069
 xfs_initialize_perag+0x1a9/0x4e0 fs/xfs/xfs_mount.c:207
 xfs_mountfs+0xbfa/0x1bf0 fs/xfs/xfs_mount.c:862
 xfs_fs_fill_super+0xd0e/0x1540 fs/xfs/xfs_super.c:1720
 mount_bdev+0x2fc/0x3b0 fs/super.c:1158
 mount_fs+0xa3/0x310 fs/super.c:1261
 vfs_kern_mount.part.0+0x68/0x470 fs/namespace.c:961
 vfs_kern_mount fs/namespace.c:951 [inline]
 do_new_mount fs/namespace.c:2492 [inline]
 do_mount+0x115c/0x2f50 fs/namespace.c:2822
 ksys_mount+0xcf/0x130 fs/namespace.c:3038
 __do_sys_mount fs/namespace.c:3052 [inline]
 __se_sys_mount fs/namespace.c:3049 [inline]
 __x64_sys_mount+0xba/0x150 fs/namespace.c:3049
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8129:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 kvfree+0x59/0x60 mm/util.c:452
 rhashtable_free_and_destroy+0x15e/0x970 lib/rhashtable.c:1167
 xfs_free_perag+0xab/0x120 fs/xfs/xfs_mount.c:152
 xfs_unmountfs+0x1d0/0x2b0 fs/xfs/xfs_mount.c:1180
 xfs_fs_put_super+0x62/0x130 fs/xfs/xfs_super.c:1774
 generic_shutdown_super+0x144/0x370 fs/super.c:456
 kill_block_super+0x97/0xf0 fs/super.c:1185
 deactivate_locked_super+0x94/0x160 fs/super.c:329
 deactivate_super+0x174/0x1a0 fs/super.c:360
 cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:193 [inline]
 exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
 do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888099771c80
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 12 bytes inside of
 512-byte region [ffff888099771c80, ffff888099771e80)
The buggy address belongs to the page:
page:ffffea000265dc40 count:1 mapcount:0 mapping:ffff88813bff0940 index:0xffff888099771000
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea000273b4c8 ffffea000289edc8 ffff88813bff0940
raw: ffff888099771000 ffff888099771000 0000000100000005 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888099771b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888099771c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888099771c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff888099771d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888099771d80: fb 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
2023/03/06 03:05 linux-4.19.y 3f8a27f9e27b f8902b57 .config console log report syz [disk image] [vmlinux] [mounted in repro] ci2-linux-4-19 KASAN: use-after-free Read in xfs_buf_rele
2022/12/15 01:45 linux-4.19.y 3f8a27f9e27b b18f0a64 .config console log report syz [disk image] [vmlinux] [mounted in repro] ci2-linux-4-19 KASAN: use-after-free Read in xfs_buf_rele
2022/12/14 21:15 linux-4.19.y 3f8a27f9e27b b18f0a64 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in xfs_buf_rele
* Struck through repros no longer work on HEAD.