[v6.1] KASAN: use-after-free Read in xfs_trans_committed_bulk

14 views
Skip to first unread message

syzbot

unread,
Mar 9, 2023, 3:20:46 AM3/9/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 42616e0f09fb Linux 6.1.15
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=15cc3a24c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=650737f7e9682672
dashboard link: https://syzkaller.appspot.com/bug?extid=252e96bafe4c37a60f97
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f10713d1fd0f/disk-42616e0f.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5a1307bb774e/vmlinux-42616e0f.xz
kernel image: https://storage.googleapis.com/syzbot-assets/388238a30fe4/Image-42616e0f.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+252e96...@syzkaller.appspotmail.com

XFS (loop3): Filesystem has been shut down due to log error (0x2).
XFS (loop3): Please unmount the filesystem and rectify the problem(s).
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x114/0x764c kernel/locking/lockdep.c:4925
Read of size 8 at addr ffff0000c92eda58 by task kworker/1:1H/51

CPU: 1 PID: 51 Comm: kworker/1:1H Not tainted 6.1.15-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: xfs-log/loop3 xlog_ioend_work
Call trace:
dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x178/0x4e0 mm/kasan/report.c:395
kasan_report+0xd4/0x130 mm/kasan/report.c:495
__asan_report_load8_noabort+0x2c/0x38 mm/kasan/report_generic.c:351
__lock_acquire+0x114/0x764c kernel/locking/lockdep.c:4925
lock_acquire+0x2f8/0x8dc kernel/locking/lockdep.c:5668
__raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
_raw_spin_lock+0x54/0x6c kernel/locking/spinlock.c:154
spin_lock include/linux/spinlock.h:350 [inline]
xfs_trans_committed_bulk+0xe4/0x73c fs/xfs/xfs_trans.c:773
xlog_cil_committed+0x210/0xef8 fs/xfs/xfs_log_cil.c:795
xlog_cil_process_committed+0x11c/0x174 fs/xfs/xfs_log_cil.c:823
xlog_state_shutdown_callbacks+0x23c/0x324 fs/xfs/xfs_log.c:538
xlog_force_shutdown+0x29c/0x350 fs/xfs/xfs_log.c:3821
xlog_ioend_work+0xa8/0xf8 fs/xfs/xfs_log.c:1402
process_one_work+0x848/0x16b4 kernel/workqueue.c:2289
worker_thread+0x8e4/0xfec kernel/workqueue.c:2436
kthread+0x24c/0x2d4 kernel/kthread.c:376
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860

Allocated by task 6593:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
kasan_save_alloc_info+0x24/0x30 mm/kasan/generic.c:505
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:211 [inline]
__do_kmalloc_node mm/slab_common.c:955 [inline]
__kmalloc+0xd8/0x1c4 mm/slab_common.c:968
kmalloc include/linux/slab.h:558 [inline]
kmem_alloc+0x278/0x690 fs/xfs/kmem.c:20
kmem_zalloc fs/xfs/kmem.h:69 [inline]
xfs_trans_ail_init+0x2c/0x220 fs/xfs/xfs_trans_ail.c:902
xfs_log_mount+0x294/0x6e0 fs/xfs/xfs_log.c:721
xfs_mountfs+0xa04/0x18fc fs/xfs/xfs_mount.c:805
xfs_fs_fill_super+0xd38/0xf50 fs/xfs/xfs_super.c:1666
get_tree_bdev+0x360/0x54c fs/super.c:1324
xfs_fs_get_tree+0x28/0x38 fs/xfs/xfs_super.c:1713
vfs_get_tree+0x90/0x274 fs/super.c:1531
do_new_mount+0x25c/0x8c8 fs/namespace.c:3040
path_mount+0x590/0xe58 fs/namespace.c:3370
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount fs/namespace.c:3568 [inline]
__arm64_sys_mount+0x45c/0x594 fs/namespace.c:3568
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

Freed by task 4350:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
kasan_save_free_info+0x38/0x5c mm/kasan/generic.c:516
____kasan_slab_free+0x144/0x20c mm/kasan/common.c:236
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:244
kasan_slab_free include/linux/kasan.h:177 [inline]
slab_free_hook mm/slub.c:1724 [inline]
slab_free_freelist_hook mm/slub.c:1750 [inline]
slab_free mm/slub.c:3661 [inline]
__kmem_cache_free+0x2c0/0x500 mm/slub.c:3674
kfree+0x104/0x268 mm/slab_common.c:1007
kvfree+0x40/0x50 mm/util.c:627
kmem_free fs/xfs/kmem.h:62 [inline]
xfs_trans_ail_destroy+0x60/0x70 fs/xfs/xfs_trans_ail.c:933
xfs_log_unmount+0x54/0xbc fs/xfs/xfs_log.c:1116
xfs_unmountfs+0x130/0x1d0 fs/xfs/xfs_mount.c:1081
xfs_fs_put_super+0x78/0x260 fs/xfs/xfs_super.c:1115
generic_shutdown_super+0x130/0x2f0 fs/super.c:492
kill_block_super+0x70/0xdc fs/super.c:1428
deactivate_locked_super+0xac/0x124 fs/super.c:332
deactivate_super+0xf0/0x110 fs/super.c:363
cleanup_mnt+0x394/0x41c fs/namespace.c:1186
__cleanup_mnt+0x20/0x30 fs/namespace.c:1193
task_work_run+0x240/0x2f0 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
do_notify_resume+0x2144/0x3470 arch/arm64/kernel/signal.c:1132
prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
el0_svc+0x9c/0x168 arch/arm64/kernel/entry-common.c:638
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

The buggy address belongs to the object at ffff0000c92eda00
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 88 bytes inside of
256-byte region [ffff0000c92eda00, ffff0000c92edb00)

The buggy address belongs to the physical page:
page:00000000f5b34839 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff0000c92ed400 pfn:0x1092ec
head:00000000f5b34839 order:1 compound_mapcount:0 compound_pincount:0
flags: 0x5ffc00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000010200 fffffc0003397200 dead000000000003 ffff0000c0002480
raw: ffff0000c92ed400 000000008010000e 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff0000c92ed900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff0000c92ed980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff0000c92eda00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff0000c92eda80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff0000c92edb00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
XFS (): xfs_trans_ail_delete: attempting to delete a log item that is not in the AIL
Unable to handle kernel paging request at virtual address e0cc707b13de1cfb
KASAN: maybe wild-memory-access in range [0x066783d89ef0e7d8-0x066783d89ef0e7df]
Mem abort info:
ESR = 0x0000000096000004
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x04: level 0 translation fault
Data abort info:
ISV = 0, ISS = 0x00000004
CM = 0, WnR = 0
[e0cc707b13de1cfb] address between user and kernel address ranges
Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
Modules linked in:
CPU: 1 PID: 51 Comm: kworker/1:1H Tainted: G B 6.1.15-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: xfs-log/loop3 xlog_ioend_work
pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : xfs_log_force+0x174/0xbcc fs/xfs/xfs_log.c:3204
lr : xfs_log_force+0x14c/0xbcc fs/xfs/xfs_log.c:3204
sp : ffff80001b257310
x29: ffff80001b257310 x28: 0000000000000001 x27: ffff800015741108
x26: dfff800000000000 x25: ffff80001568f008 x24: 066803d70000174a
x23: 066783d89ef0e7da x22: 0000000000000000 x21: ffff800009d0dfcc
x20: ffff0001043dcae0 x19: 0000000000000001 x18: 1fffe000368b3d76
x17: 6874206d65746920 x16: ffff80001219ff00 x15: 0000000000000000
x14: 0000000000000000 x13: 0000000000000001 x12: 0000000000000001
x11: ff80800009d07c40 x10: 0000000000000000 x9 : ffff800009d07c40
x8 : 00ccf07b13de1cfb x7 : 0000000000000001 x6 : 0000000000000001
x5 : ffff80001b256bb8 x4 : ffff800015823840 x3 : ffff800009d07c08
x2 : 0000000000000000 x1 : 0000000000000001 x0 : 0000000000000008
Call trace:
xfs_log_force+0x174/0xbcc fs/xfs/xfs_log.c:3204
xlog_force_shutdown+0xac/0x350 fs/xfs/xfs_log.c:3765
xfs_trans_ail_delete+0x124/0x2b0 fs/xfs/xfs_trans_ail.c:885
xfs_buf_item_done+0x58/0x94 fs/xfs/xfs_buf_item.c:1042
xfs_buf_ioend+0x3c8/0x90c fs/xfs/xfs_buf.c:1326
xfs_buf_ioend_fail+0x78/0x90 fs/xfs/xfs_buf.c:1397
xfs_buf_item_unpin+0x2e8/0xc18 fs/xfs/xfs_buf_item.c:549
xfs_trans_committed_bulk+0x2d8/0x73c fs/xfs/xfs_trans.c:806
xlog_cil_committed+0x210/0xef8 fs/xfs/xfs_log_cil.c:795
xlog_cil_process_committed+0x11c/0x174 fs/xfs/xfs_log_cil.c:823
xlog_state_shutdown_callbacks+0x23c/0x324 fs/xfs/xfs_log.c:538
xlog_force_shutdown+0x29c/0x350 fs/xfs/xfs_log.c:3821
xlog_ioend_work+0xa8/0xf8 fs/xfs/xfs_log.c:1402
process_one_work+0x848/0x16b4 kernel/workqueue.c:2289
worker_thread+0x8e4/0xfec kernel/workqueue.c:2436
kthread+0x24c/0x2d4 kernel/kthread.c:376
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860
Code: f94002e8 8b180108 91024117 d343fee8 (38fa6908)
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
0: f94002e8 ldr x8, [x23]
4: 8b180108 add x8, x8, x24
8: 91024117 add x23, x8, #0x90
c: d343fee8 lsr x8, x23, #3
* 10: 38fa6908 ldrsb w8, [x8, x26] <-- trapping instruction


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Mar 9, 2023, 9:59:46 AM3/9/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 42616e0f09fb Linux 6.1.15
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12dfa624c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=690b9ff41783cd73
dashboard link: https://syzkaller.appspot.com/bug?extid=252e96bafe4c37a60f97
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17094754c80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/db869f2ed2bd/disk-42616e0f.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/37951bbe5829/vmlinux-42616e0f.xz
kernel image: https://storage.googleapis.com/syzbot-assets/23aa1a75ce0f/bzImage-42616e0f.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/748af4666c6c/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+252e96...@syzkaller.appspotmail.com

XFS (loop0): log I/O error -5
XFS (loop0): Filesystem has been shut down due to log error (0x2).
XFS (loop0): Please unmount the filesystem and rectify the problem(s).
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x77/0x1f80 kernel/locking/lockdep.c:4925
Read of size 8 at addr ffff888023a07c58 by task kworker/1:1H/120

CPU: 1 PID: 120 Comm: kworker/1:1H Not tainted 6.1.15-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: xfs-log/loop0 xlog_ioend_work
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x15f/0x4f0 mm/kasan/report.c:395
kasan_report+0x136/0x160 mm/kasan/report.c:495
__lock_acquire+0x77/0x1f80 kernel/locking/lockdep.c:4925
lock_acquire+0x231/0x620 kernel/locking/lockdep.c:5668
__raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
_raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
spin_lock include/linux/spinlock.h:350 [inline]
xfs_trans_committed_bulk+0xd6/0x830 fs/xfs/xfs_trans.c:773
xlog_cil_committed+0x269/0xfa0 fs/xfs/xfs_log_cil.c:795
xlog_cil_process_committed+0x155/0x1a0 fs/xfs/xfs_log_cil.c:823
xlog_state_shutdown_callbacks+0x2b6/0x3a0 fs/xfs/xfs_log.c:538
xlog_force_shutdown+0x328/0x380 fs/xfs/xfs_log.c:3821
xlog_ioend_work+0xa9/0x100 fs/xfs/xfs_log.c:1402
process_one_work+0x8ee/0x1350 kernel/workqueue.c:2289
worker_thread+0xa5f/0x1210 kernel/workqueue.c:2436
kthread+0x268/0x300 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
</TASK>

Allocated by task 3900:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:211 [inline]
__do_kmalloc_node mm/slab_common.c:955 [inline]
__kmalloc+0xaf/0x1a0 mm/slab_common.c:968
kmalloc include/linux/slab.h:558 [inline]
kmem_alloc+0x1d3/0x4f0 fs/xfs/kmem.c:20
kmem_zalloc fs/xfs/kmem.h:69 [inline]
xfs_trans_ail_init+0x20/0x240 fs/xfs/xfs_trans_ail.c:902
xfs_log_mount+0x213/0x770 fs/xfs/xfs_log.c:721
xfs_mountfs+0xcbb/0x1f00 fs/xfs/xfs_mount.c:805
xfs_fs_fill_super+0xf90/0x11e0 fs/xfs/xfs_super.c:1666
get_tree_bdev+0x3fe/0x620 fs/super.c:1324
vfs_get_tree+0x88/0x270 fs/super.c:1531
do_new_mount+0x28b/0xad0 fs/namespace.c:3040
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 3641:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
kasan_slab_free include/linux/kasan.h:177 [inline]
slab_free_hook mm/slub.c:1724 [inline]
slab_free_freelist_hook mm/slub.c:1750 [inline]
slab_free mm/slub.c:3661 [inline]
__kmem_cache_free+0x25c/0x3c0 mm/slub.c:3674
xfs_log_unmount+0x51/0xc0 fs/xfs/xfs_log.c:1116
xfs_unmountfs+0x12c/0x1e0 fs/xfs/xfs_mount.c:1081
xfs_fs_put_super+0x6c/0x2c0 fs/xfs/xfs_super.c:1115
generic_shutdown_super+0x130/0x310 fs/super.c:492
kill_block_super+0x7a/0xe0 fs/super.c:1428
deactivate_locked_super+0xa0/0x110 fs/super.c:332
cleanup_mnt+0x490/0x520 fs/namespace.c:1186
task_work_run+0x246/0x300 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop+0xd9/0x100 kernel/entry/common.c:171
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:203
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x60/0x2c0 kernel/entry/common.c:296
do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888023a07c00
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 88 bytes inside of
256-byte region [ffff888023a07c00, ffff888023a07d00)

The buggy address belongs to the physical page:
page:ffffea00008e8180 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x23a06
head:ffffea00008e8180 order:1 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888012041b40
raw: 0000000000000000 0000000000100010 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 2, tgid 2 (kthreadd), ts 67648817223, free_ts 67359912076
prep_new_page mm/page_alloc.c:2539 [inline]
get_page_from_freelist+0x3542/0x36d0 mm/page_alloc.c:4291
__alloc_pages+0x28d/0x7e0 mm/page_alloc.c:5558
alloc_slab_page+0x6a/0x150 mm/slub.c:1794
allocate_slab mm/slub.c:1939 [inline]
new_slab+0x84/0x2d0 mm/slub.c:1992
___slab_alloc+0xa71/0x1080 mm/slub.c:3180
__slab_alloc mm/slub.c:3279 [inline]
slab_alloc_node mm/slub.c:3364 [inline]
__kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
kmalloc_trace+0x26/0x60 mm/slab_common.c:1045
kmalloc include/linux/slab.h:553 [inline]
kzalloc include/linux/slab.h:689 [inline]
set_kthread_struct+0xb2/0x1f0 kernel/kthread.c:117
copy_process+0x1343/0x3fd0 kernel/fork.c:2183
kernel_clone+0x222/0x9e0 kernel/fork.c:2676
kernel_thread+0x152/0x1d0 kernel/fork.c:2736
create_kthread kernel/kthread.c:399 [inline]
kthreadd+0x577/0x740 kernel/kthread.c:746
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1459 [inline]
free_pcp_prepare mm/page_alloc.c:1509 [inline]
free_unref_page_prepare+0xfdc/0x1190 mm/page_alloc.c:3387
free_unref_page+0x98/0x570 mm/page_alloc.c:3483
qlist_free_all+0x22/0x60 mm/kasan/quarantine.c:187
kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:294
__kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305
kasan_slab_alloc include/linux/kasan.h:201 [inline]
slab_post_alloc_hook+0x50/0x360 mm/slab.h:737
slab_alloc_node mm/slub.c:3398 [inline]
slab_alloc mm/slub.c:3406 [inline]
__kmem_cache_alloc_lru mm/slub.c:3413 [inline]
kmem_cache_alloc+0x119/0x260 mm/slub.c:3422
getname_flags+0xb8/0x4e0 fs/namei.c:139
user_path_at_empty+0x2a/0x180 fs/namei.c:2875
user_path_at include/linux/namei.h:57 [inline]
__do_sys_chdir fs/open.c:514 [inline]
__se_sys_chdir+0xbb/0x220 fs/open.c:508
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
ffff888023a07b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888023a07b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888023a07c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888023a07c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888023a07d00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

syzbot

unread,
Mar 10, 2023, 6:47:54 PM3/10/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 8a923980a190 Linux 6.1.16
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12a4cefac80000
kernel config: https://syzkaller.appspot.com/x/.config?x=890c08c5270b796
dashboard link: https://syzkaller.appspot.com/bug?extid=252e96bafe4c37a60f97
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15e272eac80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1709d6eac80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b5419f7c9b17/disk-8a923980.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/eda486f8541a/vmlinux-8a923980.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e1451605e837/bzImage-8a923980.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/4bf3bae92b15/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+252e96...@syzkaller.appspotmail.com

XFS (loop0): log I/O error -5
XFS (loop0): Filesystem has been shut down due to log error (0x2).
XFS (loop0): Please unmount the filesystem and rectify the problem(s).
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x77/0x1f80 kernel/locking/lockdep.c:4926
Read of size 8 at addr ffff8880741f9258 by task kworker/1:1H/52

CPU: 1 PID: 52 Comm: kworker/1:1H Not tainted 6.1.16-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: xfs-log/loop0 xlog_ioend_work
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x15f/0x4f0 mm/kasan/report.c:395
kasan_report+0x136/0x160 mm/kasan/report.c:495
__lock_acquire+0x77/0x1f80 kernel/locking/lockdep.c:4926
lock_acquire+0x23a/0x630 kernel/locking/lockdep.c:5669
__raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
_raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
spin_lock include/linux/spinlock.h:350 [inline]
xfs_trans_committed_bulk+0xd6/0x830 fs/xfs/xfs_trans.c:773
xlog_cil_committed+0x269/0xfb0 fs/xfs/xfs_log_cil.c:795
xlog_cil_process_committed+0x155/0x1a0 fs/xfs/xfs_log_cil.c:823
xlog_state_shutdown_callbacks+0x2b6/0x3a0 fs/xfs/xfs_log.c:538
xlog_force_shutdown+0x328/0x380 fs/xfs/xfs_log.c:3821
xlog_ioend_work+0xa9/0x100 fs/xfs/xfs_log.c:1402
process_one_work+0x909/0x1380 kernel/workqueue.c:2289
worker_thread+0xa5f/0x1210 kernel/workqueue.c:2436
kthread+0x268/0x300 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
</TASK>

Allocated by task 3903:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:211 [inline]
__do_kmalloc_node mm/slab_common.c:955 [inline]
__kmalloc+0xaf/0x1a0 mm/slab_common.c:968
kmalloc include/linux/slab.h:558 [inline]
kmem_alloc+0x1ea/0x500 fs/xfs/kmem.c:20
kmem_zalloc fs/xfs/kmem.h:69 [inline]
xfs_trans_ail_init+0x20/0x240 fs/xfs/xfs_trans_ail.c:902
xfs_log_mount+0x213/0x770 fs/xfs/xfs_log.c:721
xfs_mountfs+0xcbb/0x1f00 fs/xfs/xfs_mount.c:805
xfs_fs_fill_super+0xf90/0x11e0 fs/xfs/xfs_super.c:1666
get_tree_bdev+0x3fe/0x620 fs/super.c:1337
vfs_get_tree+0x88/0x270 fs/super.c:1544
do_new_mount+0x28b/0xad0 fs/namespace.c:3040
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 3672:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
kasan_slab_free include/linux/kasan.h:177 [inline]
slab_free_hook mm/slub.c:1724 [inline]
slab_free_freelist_hook mm/slub.c:1750 [inline]
slab_free mm/slub.c:3661 [inline]
__kmem_cache_free+0x25c/0x3c0 mm/slub.c:3674
xfs_log_unmount+0x51/0xc0 fs/xfs/xfs_log.c:1116
xfs_unmountfs+0x12c/0x1e0 fs/xfs/xfs_mount.c:1081
xfs_fs_put_super+0x6c/0x2c0 fs/xfs/xfs_super.c:1115
generic_shutdown_super+0x130/0x340 fs/super.c:492
kill_block_super+0x7a/0xe0 fs/super.c:1441
deactivate_locked_super+0xa0/0x110 fs/super.c:332
cleanup_mnt+0x490/0x520 fs/namespace.c:1186
task_work_run+0x246/0x300 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop+0xd9/0x100 kernel/entry/common.c:171
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:203
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x60/0x2d0 kernel/entry/common.c:296
do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff8880741f9200
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 88 bytes inside of
256-byte region [ffff8880741f9200, ffff8880741f9300)

The buggy address belongs to the physical page:
page:ffffea0001d07e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x741f8
head:ffffea0001d07e00 order:1 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888012441b40
raw: 0000000000000000 0000000080100010 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 3903, tgid 3903 (syz-executor389), ts 545314943402, free_ts 544976999463
prep_new_page mm/page_alloc.c:2539 [inline]
get_page_from_freelist+0x3573/0x3700 mm/page_alloc.c:4291
__alloc_pages+0x28d/0x7e0 mm/page_alloc.c:5558
alloc_slab_page+0x6a/0x150 mm/slub.c:1794
allocate_slab mm/slub.c:1939 [inline]
new_slab+0x84/0x2d0 mm/slub.c:1992
___slab_alloc+0xa71/0x1080 mm/slub.c:3180
__slab_alloc mm/slub.c:3279 [inline]
slab_alloc_node mm/slub.c:3364 [inline]
__kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
__do_kmalloc_node mm/slab_common.c:954 [inline]
__kmalloc+0x9e/0x1a0 mm/slab_common.c:968
kmalloc_array include/linux/slab.h:605 [inline]
kcalloc include/linux/slab.h:636 [inline]
__list_lru_init+0xa6/0x5d0 mm/list_lru.c:571
alloc_super+0x7b4/0x930 fs/super.c:272
sget_fc+0x21e/0x630 fs/super.c:573
get_tree_bdev+0x26b/0x620 fs/super.c:1305
vfs_get_tree+0x88/0x270 fs/super.c:1544
do_new_mount+0x28b/0xad0 fs/namespace.c:3040
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1459 [inline]
free_pcp_prepare mm/page_alloc.c:1509 [inline]
free_unref_page_prepare+0xfe1/0x1190 mm/page_alloc.c:3387
free_unref_page+0x98/0x570 mm/page_alloc.c:3483
qlist_free_all+0x22/0x60 mm/kasan/quarantine.c:187
kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:294
__kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305
kasan_slab_alloc include/linux/kasan.h:201 [inline]
slab_post_alloc_hook+0x50/0x370 mm/slab.h:737
slab_alloc_node mm/slub.c:3398 [inline]
slab_alloc mm/slub.c:3406 [inline]
__kmem_cache_alloc_lru mm/slub.c:3413 [inline]
kmem_cache_alloc+0x119/0x260 mm/slub.c:3422
getname_flags+0xb8/0x4e0 fs/namei.c:139
user_path_at_empty+0x2a/0x180 fs/namei.c:2875
do_readlinkat+0x114/0x3a0 fs/stat.c:468
__do_sys_readlink fs/stat.c:501 [inline]
__se_sys_readlink fs/stat.c:498 [inline]
__x64_sys_readlink+0x7b/0x90 fs/stat.c:498
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
ffff8880741f9100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880741f9180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880741f9200: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880741f9280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880741f9300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

syzbot

unread,
Oct 13, 2023, 9:50:42 PM10/13/23
to syzkaller...@googlegroups.com
syzbot suspects this issue could be fixed by backporting the following commit:

commit 1eb52a6a71981b80f9acbd915acd6a05a5037196
git tree: upstream
Author: Guo Xuenan <guox...@huawei.com>
Date: Wed Nov 30 17:25:46 2022 +0000

xfs: wait iclog complete before tearing down AIL

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=119c3d29680000
kernel config: https://syzkaller.appspot.com/x/.config?x=4a782518325cb082
dashboard link: https://syzkaller.appspot.com/bug?extid=252e96bafe4c37a60f97
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10cf20f1c80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11ddacf1c80000


Please keep in mind that other backports might be required as well.

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages