syzbot


KASAN: use-after-free Read in xfs_log_force_umount

Status: upstream: reported on 2023/02/16 12:47
Reported-by: syzbot+3d48c2932bfe773c7043@syzkaller.appspotmail.com
First crash: 485d, last: 485d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x2c57/0x3f20 kernel/locking/lockdep.c:3369
Read of size 8 at addr ffff88805db01c58 by task kworker/1:1H/2796

CPU: 1 PID: 2796 Comm: kworker/1:1H Not tainted 4.14.305-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023
Workqueue: xfs-log/loop1 xfs_buf_ioend_work
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x281 lib/dump_stack.c:58
 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:251
 kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:350
 kasan_report mm/kasan/report.c:408 [inline]
 __asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:429
 __lock_acquire+0x2c57/0x3f20 kernel/locking/lockdep.c:3369
 lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
 _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:152
 spin_lock include/linux/spinlock.h:317 [inline]
 xfs_log_force_umount+0x24b/0x430 fs/xfs/xfs_log.c:4052
 xfs_do_force_shutdown+0x78/0x200 fs/xfs/xfs_fsops.c:968
 xlog_iodone+0x15b/0x1e0 fs/xfs/xfs_log.c:1244
 xfs_buf_ioend+0x248/0x640 fs/xfs/xfs_buf.c:1191
 process_one_work+0x793/0x14a0 kernel/workqueue.c:2117
 worker_thread+0x5cc/0xff0 kernel/workqueue.c:2251
 kthread+0x30d/0x420 kernel/kthread.c:232
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:406

Allocated by task 11039:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
 __do_kmalloc mm/slab.c:3720 [inline]
 __kmalloc+0x15a/0x400 mm/slab.c:3729
 kmalloc include/linux/slab.h:493 [inline]
 kmem_alloc+0x7f/0x180 fs/xfs/kmem.c:36
 kmem_zalloc fs/xfs/kmem.h:85 [inline]
 xlog_cil_init+0x1d/0x490 fs/xfs/xfs_log_cil.c:1172
 xlog_alloc_log+0xe9d/0x1220 fs/xfs/xfs_log.c:1543
 xfs_log_mount+0xbf/0x6b0 fs/xfs/xfs_log.c:625
 xfs_mountfs+0xc5a/0x1f40 fs/xfs/xfs_mount.c:839
 xfs_fs_fill_super+0xb7a/0x1380 fs/xfs/xfs_super.c:1688
 mount_bdev+0x2b3/0x360 fs/super.c:1134
 mount_fs+0x92/0x2a0 fs/super.c:1237
 vfs_kern_mount.part.0+0x5b/0x470 fs/namespace.c:1046
 vfs_kern_mount fs/namespace.c:1036 [inline]
 do_new_mount fs/namespace.c:2572 [inline]
 do_mount+0xe65/0x2a30 fs/namespace.c:2905
 SYSC_mount fs/namespace.c:3121 [inline]
 SyS_mount+0xa8/0x120 fs/namespace.c:3098
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x5e/0xd3

Freed by task 7983:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xc9/0x250 mm/slab.c:3815
 kvfree+0x45/0x50 mm/util.c:451
 xlog_dealloc_log+0x1e/0x480 fs/xfs/xfs_log.c:1974
 xfs_unmountfs+0x1fe/0x5e0 fs/xfs/xfs_mount.c:1142
 xfs_fs_put_super+0x62/0x130 fs/xfs/xfs_super.c:1742
 generic_shutdown_super+0x144/0x370 fs/super.c:446
 kill_block_super+0x95/0xe0 fs/super.c:1161
 deactivate_locked_super+0x6c/0xd0 fs/super.c:319
 deactivate_super+0x7f/0xa0 fs/super.c:350
 cleanup_mnt+0x186/0x2c0 fs/namespace.c:1183
 task_work_run+0x11f/0x190 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
 do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
 entry_SYSCALL_64_after_hwframe+0x5e/0xd3

The buggy address belongs to the object at ffff88805db01b00
 which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 344 bytes inside of
 1024-byte region [ffff88805db01b00, ffff88805db01f00)
The buggy address belongs to the page:
page:ffffea000176c000 count:1 mapcount:0 mapping:ffff88805db00000 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffff88805db00000 0000000000000000 0000000100000007
raw: ffffea0002ae7420 ffffea000176dda0 ffff88813fe74ac0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88805db01b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805db01b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88805db01c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88805db01c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805db01d00: fb fb fb fb fb fb fb fb 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
2023/02/16 12:47 linux-4.14.y a8ad60f2af58 38b317a7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 KASAN: use-after-free Read in xfs_log_force_umount
* Struck through repros no longer work on HEAD.