[v5.15] KASAN: use-after-free Write in xfs_trans_committed_bulk

6 views
Skip to first unread message

syzbot

unread,
Mar 12, 2023, 7:46:47 AM3/12/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: d214f240b0f6 Linux 5.15.100
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=15de681ac80000
kernel config: https://syzkaller.appspot.com/x/.config?x=2ce2e44a77402c69
dashboard link: https://syzkaller.appspot.com/bug?extid=4d9a694803b65e21655b
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/16b7e741b1bc/disk-d214f240.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d659bc0db8bc/vmlinux-d214f240.xz
kernel image: https://storage.googleapis.com/syzbot-assets/64813dcb1631/Image-d214f240.gz.xz

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

XFS (loop5): log I/O error -5
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:86 [inline]
BUG: KASAN: use-after-free in set_bit include/asm-generic/bitops/instrumented-atomic.h:28 [inline]
BUG: KASAN: use-after-free in xfs_trans_committed_bulk+0x14c/0x70c fs/xfs/xfs_trans.c:757
Write of size 8 at addr ffff0000da3f1418 by task kworker/1:1H/149

CPU: 1 PID: 149 Comm: kworker/1:1H Not tainted 5.15.100-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: xfs-log/loop5 xlog_ioend_work
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
print_address_description+0x7c/0x3f0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x174/0x1e4 mm/kasan/report.c:451
kasan_check_range+0x274/0x2b4 mm/kasan/generic.c:189
__kasan_check_write+0x44/0x54 mm/kasan/shadow.c:37
instrument_atomic_write include/linux/instrumented.h:86 [inline]
set_bit include/asm-generic/bitops/instrumented-atomic.h:28 [inline]
xfs_trans_committed_bulk+0x14c/0x70c fs/xfs/xfs_trans.c:757
xlog_cil_committed+0x228/0xdd0 fs/xfs/xfs_log_cil.c:631
xlog_cil_process_committed+0x11c/0x174 fs/xfs/xfs_log_cil.c:659
xlog_state_shutdown_callbacks+0x23c/0x324 fs/xfs/xfs_log.c:516
xlog_force_shutdown+0x1a8/0x208 fs/xfs/xfs_log.c:3896
xfs_do_force_shutdown+0x118/0x7b0 fs/xfs/xfs_fsops.c:529
xlog_ioend_work+0xc0/0x114 fs/xfs/xfs_log.c:1364
process_one_work+0x84c/0x14b8 kernel/workqueue.c:2306
worker_thread+0x910/0x1034 kernel/workqueue.c:2453
kthread+0x37c/0x45c kernel/kthread.c:319
ret_from_fork+0x10/0x20 <unknown>:870

Allocated by task 5978:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:434 [inline]
__kasan_slab_alloc+0x8c/0xcc mm/kasan/common.c:467
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x74/0x3f4 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0x1dc/0x4cc mm/slub.c:3233
kmem_cache_zalloc include/linux/slab.h:711 [inline]
xfs_buf_item_init+0x70/0x434 fs/xfs/xfs_buf_item.c:807
_xfs_trans_bjoin+0x54/0x14c fs/xfs/xfs_trans_buf.c:75
xfs_trans_get_buf_map+0x44c/0xbc4 fs/xfs/xfs_trans_buf.c:162
xfs_trans_get_buf fs/xfs/xfs_trans.h:187 [inline]
xfs_dquot_disk_alloc+0x74c/0xc6c fs/xfs/xfs_dquot.c:341
xfs_qm_dqread_alloc fs/xfs/xfs_dquot.c:647 [inline]
xfs_qm_dqread+0x554/0xb64 fs/xfs/xfs_dquot.c:692
xfs_qm_dqget+0x23c/0x510 fs/xfs/xfs_dquot.c:897
xfs_qm_quotacheck_dqadjust+0xe0/0x810 fs/xfs/xfs_qm.c:1085
xfs_qm_dqusage_adjust+0x36c/0x518 fs/xfs/xfs_qm.c:1190
xfs_iwalk_ag_recs+0x514/0x9cc fs/xfs/xfs_iwalk.c:220
xfs_iwalk_run_callbacks+0x1bc/0x3b4 fs/xfs/xfs_iwalk.c:376
xfs_iwalk_ag+0x8d4/0x9b0 fs/xfs/xfs_iwalk.c:482
xfs_iwalk_ag_work+0x10c/0x1a8 fs/xfs/xfs_iwalk.c:624
xfs_pwork_work+0x80/0x1b8 fs/xfs/xfs_pwork.c:47
process_one_work+0x84c/0x14b8 kernel/workqueue.c:2306
worker_thread+0x910/0x1034 kernel/workqueue.c:2453
kthread+0x37c/0x45c kernel/kthread.c:319
ret_from_fork+0x10/0x20 <unknown>:870

Freed by task 12454:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4c/0x84 mm/kasan/common.c:46
kasan_set_free_info+0x28/0x4c mm/kasan/generic.c:360
____kasan_slab_free+0x118/0x164 mm/kasan/common.c:366
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0x128/0x1ec mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kmem_cache_free+0xdc/0x434 mm/slub.c:3515
xfs_buf_item_free+0x54/0x64 fs/xfs/xfs_buf_item.c:1005
xfs_buf_item_relse+0x280/0x57c fs/xfs/xfs_buf_item.c:1022
xfs_buf_item_done+0x60/0x94 fs/xfs/xfs_buf_item.c:1044
xfs_buf_ioend+0x438/0x940 fs/xfs/xfs_buf.c:1286
xfs_buf_ioend_fail+0x78/0x90 fs/xfs/xfs_buf.c:1357
__xfs_buf_submit+0x2d8/0x9fc fs/xfs/xfs_buf.c:1598
xfs_buf_delwri_submit_buffers+0x6c0/0xaf8 fs/xfs/xfs_buf.c:2136
xfs_buf_delwri_submit+0xbc/0x244 fs/xfs/xfs_buf.c:2182
xfs_qm_quotacheck+0x34c/0x56c fs/xfs/xfs_qm.c:1351
xfs_qm_mount_quotas+0x2ac/0x578 fs/xfs/xfs_qm.c:1441
xfs_mountfs+0x11e4/0x1778 fs/xfs/xfs_mount.c:904
xfs_fs_fill_super+0xd64/0xf60 fs/xfs/xfs_super.c:1658
get_tree_bdev+0x360/0x54c fs/super.c:1294
xfs_fs_get_tree+0x28/0x38 fs/xfs/xfs_super.c:1705
vfs_get_tree+0x90/0x274 fs/super.c:1499
do_new_mount+0x25c/0x8c8 fs/namespace.c:2994
path_mount+0x590/0x104c fs/namespace.c:3324
do_mount fs/namespace.c:3337 [inline]
__do_sys_mount fs/namespace.c:3545 [inline]
__se_sys_mount fs/namespace.c:3522 [inline]
__arm64_sys_mount+0x510/0x5e0 fs/namespace.c:3522
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

The buggy address belongs to the object at ffff0000da3f13d8
which belongs to the cache xfs_buf_item of size 264
The buggy address is located 64 bytes inside of
264-byte region [ffff0000da3f13d8, ffff0000da3f14e0)
The buggy address belongs to the page:
page:000000009d417726 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11a3f1
flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000000200 fffffc00031f5580 0000000200000002 ffff0000c6380780
raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff0000da3f1300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff0000da3f1380: fb fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb
>ffff0000da3f1400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff0000da3f1480: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff0000da3f1500: fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb fb
==================================================================
==================================================================
BUG: KASAN: double-free or invalid-free in slab_free mm/slub.c:3499 [inline]
BUG: KASAN: double-free or invalid-free in kfree+0x1b0/0x480 mm/slub.c:4559

CPU: 1 PID: 149 Comm: kworker/1:1H Tainted: G B 5.15.100-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: xfs-log/loop5 xlog_ioend_work
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
print_address_description+0x7c/0x3f0 mm/kasan/report.c:248
kasan_report_invalid_free+0x64/0x94 mm/kasan/report.c:373
____kasan_slab_free+0x134/0x164
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0x128/0x1ec mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kfree+0x1b0/0x480 mm/slub.c:4559
kvfree+0x40/0x50 mm/util.c:654
kmem_free fs/xfs/kmem.h:62 [inline]
xfs_buf_free+0x2b0/0x638 fs/xfs/xfs_buf.c:307
xfs_buf_rele+0x103c/0x171c
xfs_buf_relse fs/xfs/xfs_buf.h:270 [inline]
xfs_buf_ioend+0x548/0x940 fs/xfs/xfs_buf.c:1299
xfs_buf_ioend_fail+0x78/0x90 fs/xfs/xfs_buf.c:1357
xfs_buf_item_unpin+0x2f4/0xb48 fs/xfs/xfs_buf_item.c:548
xfs_trans_committed_bulk+0x2b0/0x70c fs/xfs/xfs_trans.c:780
xlog_cil_committed+0x228/0xdd0 fs/xfs/xfs_log_cil.c:631
xlog_cil_process_committed+0x11c/0x174 fs/xfs/xfs_log_cil.c:659
xlog_state_shutdown_callbacks+0x23c/0x324 fs/xfs/xfs_log.c:516
xlog_force_shutdown+0x1a8/0x208 fs/xfs/xfs_log.c:3896
xfs_do_force_shutdown+0x118/0x7b0 fs/xfs/xfs_fsops.c:529
xlog_ioend_work+0xc0/0x114 fs/xfs/xfs_log.c:1364
process_one_work+0x84c/0x14b8 kernel/workqueue.c:2306
worker_thread+0x910/0x1034 kernel/workqueue.c:2453
kthread+0x37c/0x45c kernel/kthread.c:319
ret_from_fork+0x10/0x20 <unknown>:870

Allocated by task 5978:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:434 [inline]
____kasan_kmalloc+0xbc/0xfc mm/kasan/common.c:513
__kasan_kmalloc+0x10/0x1c mm/kasan/common.c:522
kasan_kmalloc include/linux/kasan.h:264 [inline]
__kmalloc+0x26c/0x404 mm/slub.c:4407
kmalloc include/linux/slab.h:596 [inline]
kmem_alloc+0x2ec/0x6c8 fs/xfs/kmem.c:21
xfs_buf_alloc_kmem fs/xfs/xfs_buf.c:325 [inline]
xfs_buf_get_map+0x670/0xd50 fs/xfs/xfs_buf.c:670
xfs_trans_get_buf_map+0x184/0xbc4 fs/xfs/xfs_trans_buf.c:156
xfs_trans_get_buf fs/xfs/xfs_trans.h:187 [inline]
xfs_dquot_disk_alloc+0x74c/0xc6c fs/xfs/xfs_dquot.c:341
xfs_qm_dqread_alloc fs/xfs/xfs_dquot.c:647 [inline]
xfs_qm_dqread+0x554/0xb64 fs/xfs/xfs_dquot.c:692
xfs_qm_dqget+0x23c/0x510 fs/xfs/xfs_dquot.c:897
xfs_qm_quotacheck_dqadjust+0xe0/0x810 fs/xfs/xfs_qm.c:1085
xfs_qm_dqusage_adjust+0x36c/0x518 fs/xfs/xfs_qm.c:1190
xfs_iwalk_ag_recs+0x514/0x9cc fs/xfs/xfs_iwalk.c:220
xfs_iwalk_run_callbacks+0x1bc/0x3b4 fs/xfs/xfs_iwalk.c:376
xfs_iwalk_ag+0x8d4/0x9b0 fs/xfs/xfs_iwalk.c:482
xfs_iwalk_ag_work+0x10c/0x1a8 fs/xfs/xfs_iwalk.c:624
xfs_pwork_work+0x80/0x1b8 fs/xfs/xfs_pwork.c:47
process_one_work+0x84c/0x14b8 kernel/workqueue.c:2306
worker_thread+0x910/0x1034 kernel/workqueue.c:2453
kthread+0x37c/0x45c kernel/kthread.c:319
ret_from_fork+0x10/0x20 <unknown>:870

Freed by task 12454:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4c/0x84 mm/kasan/common.c:46
kasan_set_free_info+0x28/0x4c mm/kasan/generic.c:360
____kasan_slab_free+0x118/0x164 mm/kasan/common.c:366
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0x128/0x1ec mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kfree+0x1b0/0x480 mm/slub.c:4559
kvfree+0x40/0x50 mm/util.c:654
kmem_free fs/xfs/kmem.h:62 [inline]
xfs_buf_free+0x2b0/0x638 fs/xfs/xfs_buf.c:307
xfs_buf_rele+0x103c/0x171c
xfs_buf_relse fs/xfs/xfs_buf.h:270 [inline]
xfs_buf_delwri_submit+0x1ac/0x244 fs/xfs/xfs_buf.c:2195
xfs_qm_quotacheck+0x34c/0x56c fs/xfs/xfs_qm.c:1351
xfs_qm_mount_quotas+0x2ac/0x578 fs/xfs/xfs_qm.c:1441
xfs_mountfs+0x11e4/0x1778 fs/xfs/xfs_mount.c:904
xfs_fs_fill_super+0xd64/0xf60 fs/xfs/xfs_super.c:1658
get_tree_bdev+0x360/0x54c fs/super.c:1294
xfs_fs_get_tree+0x28/0x38 fs/xfs/xfs_super.c:1705
vfs_get_tree+0x90/0x274 fs/super.c:1499
do_new_mount+0x25c/0x8c8 fs/namespace.c:2994
path_mount+0x590/0x104c fs/namespace.c:3324
do_mount fs/namespace.c:3337 [inline]
__do_sys_mount fs/namespace.c:3545 [inline]
__se_sys_mount fs/namespace.c:3522 [inline]
__arm64_sys_mount+0x510/0x5e0 fs/namespace.c:3522
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

Last potentially related work creation:
kasan_save_stack+0x38/0x68 mm/kasan/common.c:38
kasan_record_aux_stack+0xd4/0x11c mm/kasan/generic.c:348
__call_rcu kernel/rcu/tree.c:2993 [inline]
call_rcu+0x118/0xb40 kernel/rcu/tree.c:3073
fib6_info_release include/net/ip6_fib.h:339 [inline]
ip6_route_info_create+0x818/0xf28 net/ipv6/route.c:3854
ip6_route_add+0x38/0x17c net/ipv6/route.c:3868
addrconf_prefix_route+0x280/0x3fc net/ipv6/addrconf.c:2429
inet6_addr_add+0x404/0x81c net/ipv6/addrconf.c:2975
inet6_rtm_newaddr+0x6a4/0x1de4 net/ipv6/addrconf.c:4927
rtnetlink_rcv_msg+0xa74/0xdac net/core/rtnetlink.c:5587
netlink_rcv_skb+0x20c/0x3b8 net/netlink/af_netlink.c:2533
rtnetlink_rcv+0x28/0x38 net/core/rtnetlink.c:5605
netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
netlink_unicast+0x664/0x938 net/netlink/af_netlink.c:1356
netlink_sendmsg+0x844/0xb38 net/netlink/af_netlink.c:1952
sock_sendmsg_nosec net/socket.c:704 [inline]
sock_sendmsg net/socket.c:724 [inline]
__sys_sendto+0x388/0x4d0 net/socket.c:2039
__do_sys_sendto net/socket.c:2051 [inline]
__se_sys_sendto net/socket.c:2047 [inline]
__arm64_sys_sendto+0xd8/0xf8 net/socket.c:2047
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

The buggy address belongs to the object at ffff00010c2cd000
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 0 bytes inside of
512-byte region [ffff00010c2cd000, ffff00010c2cd200)
The buggy address belongs to the page:
page:000000001aac5dbf refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x14c2cc
head:000000001aac5dbf order:2 compound_mapcount:0 compound_pincount:0
flags: 0x5ffc00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000010200 dead000000000100 dead000000000122 ffff0000c0002600
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff00010c2ccf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff00010c2ccf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff00010c2cd000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff00010c2cd080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff00010c2cd100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
==================================================================
BUG: KASAN: double-free or invalid-free in slab_free mm/slub.c:3499 [inline]
BUG: KASAN: double-free or invalid-free in kmem_cache_free+0xdc/0x434 mm/slub.c:3515

CPU: 1 PID: 149 Comm: kworker/1:1H Tainted: G B 5.15.100-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: xfs-log/loop5 xlog_ioend_work
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
print_address_description+0x7c/0x3f0 mm/kasan/report.c:248
kasan_report_invalid_free+0x64/0x94 mm/kasan/report.c:373
____kasan_slab_free+0x134/0x164
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0x128/0x1ec mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kmem_cache_free+0xdc/0x434 mm/slub.c:3515
xfs_buf_free+0x310/0x638 fs/xfs/xfs_buf.c:310
xfs_buf_rele+0x103c/0x171c
xfs_buf_relse fs/xfs/xfs_buf.h:270 [inline]
xfs_buf_ioend+0x548/0x940 fs/xfs/xfs_buf.c:1299
xfs_buf_ioend_fail+0x78/0x90 fs/xfs/xfs_buf.c:1357
xfs_buf_item_unpin+0x2f4/0xb48 fs/xfs/xfs_buf_item.c:548
xfs_trans_committed_bulk+0x2b0/0x70c fs/xfs/xfs_trans.c:780
xlog_cil_committed+0x228/0xdd0 fs/xfs/xfs_log_cil.c:631
xlog_cil_process_committed+0x11c/0x174 fs/xfs/xfs_log_cil.c:659
xlog_state_shutdown_callbacks+0x23c/0x324 fs/xfs/xfs_log.c:516
xlog_force_shutdown+0x1a8/0x208 fs/xfs/xfs_log.c:3896
xfs_do_force_shutdown+0x118/0x7b0 fs/xfs/xfs_fsops.c:529
xlog_ioend_work+0xc0/0x114 fs/xfs/xfs_log.c:1364
process_one_work+0x84c/0x14b8 kernel/workqueue.c:2306
worker_thread+0x910/0x1034 kernel/workqueue.c:2453
kthread+0x37c/0x45c kernel/kthread.c:319
ret_from_fork+0x10/0x20 <unknown>:870

Allocated by task 5978:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:434 [inline]
__kasan_slab_alloc+0x8c/0xcc mm/kasan/common.c:467
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x74/0x3f4 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0x1dc/0x4cc mm/slub.c:3233
kmem_cache_zalloc include/linux/slab.h:711 [inline]
_xfs_buf_alloc+0x78/0xec8 fs/xfs/xfs_buf.c:223
xfs_buf_get_map+0x194/0xd50 fs/xfs/xfs_buf.c:659
xfs_trans_get_buf_map+0x184/0xbc4 fs/xfs/xfs_trans_buf.c:156
xfs_trans_get_buf fs/xfs/xfs_trans.h:187 [inline]
xfs_dquot_disk_alloc+0x74c/0xc6c fs/xfs/xfs_dquot.c:341
xfs_qm_dqread_alloc fs/xfs/xfs_dquot.c:647 [inline]
xfs_qm_dqread+0x554/0xb64 fs/xfs/xfs_dquot.c:692
xfs_qm_dqget+0x23c/0x510 fs/xfs/xfs_dquot.c:897
xfs_qm_quotacheck_dqadjust+0xe0/0x810 fs/xfs/xfs_qm.c:1085
xfs_qm_dqusage_adjust+0x36c/0x518 fs/xfs/xfs_qm.c:1190
xfs_iwalk_ag_recs+0x514/0x9cc fs/xfs/xfs_iwalk.c:220
xfs_iwalk_run_callbacks+0x1bc/0x3b4 fs/xfs/xfs_iwalk.c:376
xfs_iwalk_ag+0x8d4/0x9b0 fs/xfs/xfs_iwalk.c:482
xfs_iwalk_ag_work+0x10c/0x1a8 fs/xfs/xfs_iwalk.c:624
xfs_pwork_work+0x80/0x1b8 fs/xfs/xfs_pwork.c:47
process_one_work+0x84c/0x14b8 kernel/workqueue.c:2306
worker_thread+0x910/0x1034 kernel/workqueue.c:2453
kthread+0x37c/0x45c kernel/kthread.c:319
ret_from_fork+0x10/0x20 <unknown>:870

Freed by task 12454:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4c/0x84 mm/kasan/common.c:46
kasan_set_free_info+0x28/0x4c mm/kasan/generic.c:360
____kasan_slab_free+0x118/0x164 mm/kasan/common.c:366
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0x128/0x1ec mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kmem_cache_free+0xdc/0x434 mm/slub.c:3515
xfs_buf_free+0x310/0x638 fs/xfs/xfs_buf.c:310
xfs_buf_rele+0x103c/0x171c
xfs_buf_relse fs/xfs/xfs_buf.h:270 [inline]
xfs_buf_delwri_submit+0x1ac/0x244 fs/xfs/xfs_buf.c:2195
xfs_qm_quotacheck+0x34c/0x56c fs/xfs/xfs_qm.c:1351
xfs_qm_mount_quotas+0x2ac/0x578 fs/xfs/xfs_qm.c:1441
xfs_mountfs+0x11e4/0x1778 fs/xfs/xfs_mount.c:904
xfs_fs_fill_super+0xd64/0xf60 fs/xfs/xfs_super.c:1658
get_tree_bdev+0x360/0x54c fs/super.c:1294
xfs_fs_get_tree+0x28/0x38 fs/xfs/xfs_super.c:1705
vfs_get_tree+0x90/0x274 fs/super.c:1499
do_new_mount+0x25c/0x8c8 fs/namespace.c:2994
path_mount+0x590/0x104c fs/namespace.c:3324
do_mount fs/namespace.c:3337 [inline]
__do_sys_mount fs/namespace.c:3545 [inline]
__se_sys_mount fs/namespace.c:3522 [inline]
__arm64_sys_mount+0x510/0x5e0 fs/namespace.c:3522
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

The buggy address belongs to the object at ffff00010e086d00
which belongs to the cache xfs_buf of size 632
The buggy address is located 0 bytes inside of
632-byte region [ffff00010e086d00, ffff00010e086f78)
The buggy address belongs to the page:
page:00000000d1fb0ad5 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x14e084
head:00000000d1fb0ad5 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x5ffc00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000010200 0000000000000000 dead000000000122 ffff0000c6381980
raw: 0000000000000000 0000000080150015 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff00010e086c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc
ffff00010e086c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff00010e086d00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff00010e086d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff00010e086e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
XFS (loop5): Log I/O Error (0x2) detected at xlog_ioend_work+0xc0/0x114 fs/xfs/xfs_log.c:1364 (fs/xfs/xfs_log.c:1364). Shutting down filesystem.
XFS (loop5): Please unmount the filesystem and rectify the problem(s)
XFS (loop5): log I/O error -5
XFS (loop5): Log I/O Error (0x2) detected at xlog_ioend_work+0xc0/0x114 fs/xfs/xfs_log.c:1364 (fs/xfs/xfs_log.c:1364). Shutting down filesystem.
XFS (loop5): Please unmount the filesystem and rectify the problem(s)
XFS (loop5): log I/O error -5
XFS (loop5): Log I/O Error (0x2) detected at xlog_ioend_work+0xc0/0x114 fs/xfs/xfs_log.c:1364 (fs/xfs/xfs_log.c:1364). Shutting down filesystem.
XFS (loop5): Please unmount the filesystem and rectify the problem(s)
XFS (loop5): log I/O error -5
XFS (loop5): Log I/O Error (0x2) detected at xlog_ioend_work+0xc0/0x114 fs/xfs/xfs_log.c:1364 (fs/xfs/xfs_log.c:1364). Shutting down filesystem.
XFS (loop5): Please unmount the filesystem and rectify the problem(s)


---
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 14, 2023, 2:14:47 AM3/14/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 2ddbd0f967b3 Linux 5.15.102
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=116b8152c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=fec083380faceb1e
dashboard link: https://syzkaller.appspot.com/bug?extid=4d9a694803b65e21655b
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=1380251ac80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=170aa6ecc80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/156d2aa91f3c/disk-2ddbd0f9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f0e97f5be5fb/vmlinux-2ddbd0f9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/20d0a55a041d/bzImage-2ddbd0f9.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/ba49b5f9d099/mount_4.gz

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

XFS (loop0): log I/O error -5
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:86 [inline]
BUG: KASAN: use-after-free in set_bit include/asm-generic/bitops/instrumented-atomic.h:28 [inline]
BUG: KASAN: use-after-free in xfs_trans_committed_bulk+0x158/0x7f0 fs/xfs/xfs_trans.c:757
Write of size 8 at addr ffff8880752db560 by task kworker/1:1H/150

CPU: 1 PID: 150 Comm: kworker/1:1H Not tainted 5.15.102-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+0x63/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
instrument_atomic_write include/linux/instrumented.h:86 [inline]
set_bit include/asm-generic/bitops/instrumented-atomic.h:28 [inline]
xfs_trans_committed_bulk+0x158/0x7f0 fs/xfs/xfs_trans.c:757
xlog_cil_committed+0x28d/0xe50 fs/xfs/xfs_log_cil.c:631
xlog_cil_process_committed+0x155/0x1a0 fs/xfs/xfs_log_cil.c:659
xlog_state_shutdown_callbacks+0x2b6/0x3a0 fs/xfs/xfs_log.c:516
xlog_force_shutdown+0x1e7/0x200 fs/xfs/xfs_log.c:3896
xfs_do_force_shutdown+0x11d/0x520 fs/xfs/xfs_fsops.c:529
xlog_ioend_work+0xc2/0x120 fs/xfs/xfs_log.c:1364
process_one_work+0x90d/0x1270 kernel/workqueue.c:2306
worker_thread+0xaca/0x1280 kernel/workqueue.c:2453
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 <unknown>:298
</TASK>

Allocated by task 1197:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:434 [inline]
__kasan_slab_alloc+0x8e/0xc0 mm/kasan/common.c:467
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0xf3/0x2e0 mm/slub.c:3233
kmem_cache_zalloc include/linux/slab.h:711 [inline]
xfs_buf_item_init+0x68/0x4e0 fs/xfs/xfs_buf_item.c:807
_xfs_trans_bjoin+0x44/0x100 fs/xfs/xfs_trans_buf.c:75
xfs_trans_get_buf_map+0x424/0x9b0 fs/xfs/xfs_trans_buf.c:162
xfs_trans_get_buf fs/xfs/xfs_trans.h:187 [inline]
xfs_dquot_disk_alloc+0x7a2/0xc40 fs/xfs/xfs_dquot.c:341
xfs_qm_dqread_alloc fs/xfs/xfs_dquot.c:647 [inline]
xfs_qm_dqread+0x2ca/0x940 fs/xfs/xfs_dquot.c:692
xfs_qm_dqget+0x26f/0x4e0 fs/xfs/xfs_dquot.c:897
xfs_qm_quotacheck_dqadjust+0xe6/0x630 fs/xfs/xfs_qm.c:1085
xfs_qm_dqusage_adjust+0x44f/0x670 fs/xfs/xfs_qm.c:1190
xfs_iwalk_ag_recs+0x53b/0x8f0 fs/xfs/xfs_iwalk.c:220
xfs_iwalk_run_callbacks+0x211/0x420 fs/xfs/xfs_iwalk.c:376
xfs_iwalk_ag+0xad2/0xbd0 fs/xfs/xfs_iwalk.c:482
xfs_iwalk_ag_work+0xf7/0x1a0 fs/xfs/xfs_iwalk.c:624
xfs_pwork_work+0x78/0x180 fs/xfs/xfs_pwork.c:47
process_one_work+0x90d/0x1270 kernel/workqueue.c:2306
worker_thread+0xaca/0x1280 kernel/workqueue.c:2453
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 <unknown>:298

Freed by task 4046:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kmem_cache_free+0x91/0x260 mm/slub.c:3515
xfs_buf_ioend+0x3dc/0x7e0 fs/xfs/xfs_buf.c:1286
__xfs_buf_submit+0x1e6/0x860 fs/xfs/xfs_buf.c:1598
xfs_buf_delwri_submit_buffers+0x6e5/0x9d0 fs/xfs/xfs_buf.c:2136
xfs_buf_delwri_submit+0xb6/0x260 fs/xfs/xfs_buf.c:2182
xfs_qm_quotacheck+0x3df/0x640 fs/xfs/xfs_qm.c:1351
xfs_qm_mount_quotas+0x328/0x610 fs/xfs/xfs_qm.c:1441
xfs_mountfs+0x162b/0x1ca0 fs/xfs/xfs_mount.c:904
xfs_fs_fill_super+0x100c/0x1240 fs/xfs/xfs_super.c:1658
get_tree_bdev+0x3fe/0x620 fs/super.c:1294
vfs_get_tree+0x88/0x270 fs/super.c:1499
do_new_mount+0x28b/0xad0 fs/namespace.c:2994
do_mount fs/namespace.c:3337 [inline]
__do_sys_mount fs/namespace.c:3545 [inline]
__se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3522
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+0x61/0xcb

The buggy address belongs to the object at ffff8880752db520
which belongs to the cache xfs_buf_item of size 264
The buggy address is located 64 bytes inside of
264-byte region [ffff8880752db520, ffff8880752db628)
The buggy address belongs to the page:
page:ffffea0001d4b6c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x752db
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea00008ceb80 0000000200000002 ffff88814629eb40
raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY), pid 3703, ts 193470335433, free_ts 192929439969
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x32dd/0x3470 mm/page_alloc.c:4159
__alloc_pages+0x272/0x790 mm/page_alloc.c:5421
alloc_slab_page mm/slub.c:1775 [inline]
allocate_slab mm/slub.c:1912 [inline]
new_slab+0xbb/0x4b0 mm/slub.c:1975
___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
__slab_alloc mm/slub.c:3095 [inline]
slab_alloc_node mm/slub.c:3186 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0x1e1/0x2e0 mm/slub.c:3233
kmem_cache_zalloc include/linux/slab.h:711 [inline]
xfs_buf_item_init+0x68/0x4e0 fs/xfs/xfs_buf_item.c:807
_xfs_trans_bjoin+0x44/0x100 fs/xfs/xfs_trans_buf.c:75
xfs_trans_read_buf_map+0x339/0xc30 fs/xfs/xfs_trans_buf.c:310
xfs_trans_read_buf fs/xfs/xfs_trans.h:210 [inline]
xfs_imap_to_bp+0x154/0x1b0 fs/xfs/libxfs/xfs_inode_buf.c:136
xfs_iget_cache_miss fs/xfs/xfs_icache.c:620 [inline]
xfs_iget+0xe4e/0x3450 fs/xfs/xfs_icache.c:762
xfs_init_new_inode+0x1d4/0x1100 fs/xfs/xfs_inode.c:830
xfs_qm_qino_alloc+0x516/0x9c0 fs/xfs/xfs_qm.c:790
xfs_qm_init_quotainos+0x61e/0x8a0 fs/xfs/xfs_qm.c:1544
xfs_qm_init_quotainfo+0xa6/0xa40 fs/xfs/xfs_qm.c:644
xfs_qm_mount_quotas+0x90/0x610 fs/xfs/xfs_qm.c:1428
xfs_mountfs+0x162b/0x1ca0 fs/xfs/xfs_mount.c:904
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1340 [inline]
free_pcp_prepare mm/page_alloc.c:1391 [inline]
free_unref_page_prepare+0xcb7/0xd70 mm/page_alloc.c:3317
free_unref_page_list+0x1f7/0x970 mm/page_alloc.c:3433
release_pages+0x1bb9/0x1f40 mm/swap.c:963
__pagevec_release+0x80/0xf0 mm/swap.c:983
pagevec_release include/linux/pagevec.h:81 [inline]
truncate_inode_pages_range+0x48b/0x1290 mm/truncate.c:329
kill_bdev block/bdev.c:77 [inline]
blkdev_flush_mapping+0x182/0x340 block/bdev.c:659
blkdev_put_whole block/bdev.c:690 [inline]
blkdev_put+0x4f1/0x790 block/bdev.c:954
deactivate_locked_super+0xa0/0x110 fs/super.c:335
cleanup_mnt+0x44e/0x500 fs/namespace.c:1143
task_work_run+0x129/0x1a0 kernel/task_work.c:164
tracehook_notify_resume include/linux/tracehook.h:189 [inline]
exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:175
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:207
__syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
syscall_exit_to_user_mode+0x5d/0x2b0 kernel/entry/common.c:300
do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
ffff8880752db400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880752db480: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff8880752db500: fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880752db580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880752db600: fb fb fb fb fb fc fc fc fc fc fc fc fc fb fb fb
==================================================================

syzbot

unread,
Sep 14, 2023, 5:24:43 AM9/14/23
to syzkaller...@googlegroups.com
syzbot suspects this issue could be fixed by backporting the following commit:

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

xfs: fix super block buf log item UAF during force shutdown

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=107e73bfa80000
kernel config: https://syzkaller.appspot.com/x/.config?x=6f83fab0469f5de7
dashboard link: https://syzkaller.appspot.com/bug?extid=4d9a694803b65e21655b
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10ecd4edc80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17277ae1c80000


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