[xfs?] KASAN: use-after-free Write in list_sort

9 views
Skip to first unread message

syzbot

unread,
Jan 17, 2023, 7:18:52 PM1/17/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c4215ee4771b Linux 4.14.302
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1509f77e480000
kernel config: https://syzkaller.appspot.com/x/.config?x=4a9988fe055c9527
dashboard link: https://syzkaller.appspot.com/bug?extid=f632f1268ced221d14f2
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c93ba055d204/disk-c4215ee4.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/bfbc929a33c1/vmlinux-c4215ee4.xz
kernel image: https://storage.googleapis.com/syzbot-assets/444658051770/bzImage-c4215ee4.xz

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

XFS (loop5): Quotacheck needed: Please wait.
syz-executor.1 (9818): drop_caches: 2
syz-executor.2 (9817): drop_caches: 2
syz-executor.1 (9818): drop_caches: 2
==================================================================
BUG: KASAN: use-after-free in list_sort.part.0+0x693/0x6d0 lib/list_sort.c:117
Write of size 8 at addr ffff8880a34c9788 by task syz-executor.5/9759
syz-executor.2 (9817): drop_caches: 2

CPU: 0 PID: 9759 Comm: syz-executor.5 Not tainted 4.14.302-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
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:252
kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
kasan_report mm/kasan/report.c:409 [inline]
__asan_report_store8_noabort+0x68/0x70 mm/kasan/report.c:435
list_sort.part.0+0x693/0x6d0 lib/list_sort.c:117
list_sort+0x46/0x60 lib/list_sort.c:112
xfs_buf_delwri_submit_buffers+0x96/0x9c0 fs/xfs/xfs_buf.c:1992
xfs_buf_delwri_submit+0x76/0x240 fs/xfs/xfs_buf.c:2075
xfs_qm_quotacheck+0x2a7/0x790 fs/xfs/xfs_qm.c:1367
xfs_qm_mount_quotas+0xe9/0x570 fs/xfs/xfs_qm.c:1457
xfs_mountfs+0x18be/0x1f40 fs/xfs/xfs_mount.c:979
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
RIP: 0033:0x7fa5f4a085fa
RSP: 002b:00007fa5f2f78f88 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 000000000000baed RCX: 00007fa5f4a085fa
RDX: 000000002000bb00 RSI: 0000000020000040 RDI: 00007fa5f2f78fe0
RBP: 00007fa5f2f79020 R08: 00007fa5f2f79020 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 000000002000bb00
R13: 0000000020000040 R14: 00007fa5f2f78fe0 R15: 0000000020000000

Allocated by task 9759:
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
kmem_cache_alloc+0x124/0x3c0 mm/slab.c:3552
kmem_zone_alloc+0x7f/0x180 fs/xfs/kmem.c:106
kmem_zone_zalloc fs/xfs/kmem.h:131 [inline]
_xfs_buf_alloc+0x32/0xcf0 fs/xfs/xfs_buf.c:248
xfs_buf_get_map+0x436/0x5f0 fs/xfs/xfs_buf.c:695
xfs_trans_get_buf_map+0x277/0x710 fs/xfs/xfs_trans_buf.c:170
xfs_trans_get_buf fs/xfs/xfs_trans.h:179 [inline]
xfs_qm_dqalloc+0x5e6/0xa20 fs/xfs/xfs_dquot.c:354
xfs_qm_dqtobp+0x926/0xcf0 fs/xfs/xfs_dquot.c:518
xfs_qm_dqread+0x3a3/0xe50 fs/xfs/xfs_dquot.c:629
xfs_qm_dqget+0x4f4/0x19a0 fs/xfs/xfs_dquot.c:837
xfs_qm_quotacheck_dqadjust+0x96/0x5c0 fs/xfs/xfs_qm.c:1077
xfs_qm_dqusage_adjust+0x428/0xc20 fs/xfs/xfs_qm.c:1192
xfs_bulkstat_ag_ichunk fs/xfs/xfs_itable.c:313 [inline]
xfs_bulkstat+0x72a/0xf60 fs/xfs/xfs_itable.c:498
xfs_qm_quotacheck+0x223/0x790 fs/xfs/xfs_qm.c:1338
xfs_qm_mount_quotas+0xe9/0x570 fs/xfs/xfs_qm.c:1457
xfs_mountfs+0x18be/0x1f40 fs/xfs/xfs_mount.c:979
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 9817:
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]
kmem_cache_free+0x7c/0x2b0 mm/slab.c:3758
xfs_buf_rele+0x810/0x12a0 fs/xfs/xfs_buf.c:1074
xfs_buftarg_shrink_scan+0x18a/0x270 fs/xfs/xfs_buf.c:1769
do_shrink_slab mm/vmscan.c:401 [inline]
shrink_slab+0x535/0xb60 mm/vmscan.c:504
drop_slab_node+0x2b/0x60 mm/vmscan.c:531
drop_slab+0x39/0x70 mm/vmscan.c:542
drop_caches_sysctl_handler+0xc9/0xe0 fs/drop_caches.c:65
proc_sys_call_handler.isra.0+0x1ba/0x340 fs/proc/proc_sysctl.c:598
__vfs_write+0xe4/0x630 fs/read_write.c:480
__kernel_write+0xf5/0x330 fs/read_write.c:501
write_pipe_buf+0x143/0x1c0 fs/splice.c:797
splice_from_pipe_feed fs/splice.c:502 [inline]
__splice_from_pipe+0x326/0x7a0 fs/splice.c:626
splice_from_pipe fs/splice.c:661 [inline]
default_file_splice_write+0xc5/0x150 fs/splice.c:809
do_splice_from fs/splice.c:851 [inline]
direct_splice_actor+0x115/0x160 fs/splice.c:1018
splice_direct_to_actor+0x27c/0x730 fs/splice.c:973
do_splice_direct+0x164/0x210 fs/splice.c:1061
do_sendfile+0x47f/0xb30 fs/read_write.c:1441
SYSC_sendfile64 fs/read_write.c:1496 [inline]
SyS_sendfile64+0x9b/0x110 fs/read_write.c:1488
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

The buggy address belongs to the object at ffff8880a34c9680
which belongs to the cache xfs_buf of size 584
The buggy address is located 264 bytes inside of
584-byte region [ffff8880a34c9680, ffff8880a34c98c8)
The buggy address belongs to the page:
page:ffffea00028d3240 count:1 mapcount:0 mapping:ffff8880a34c9080 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff8880a34c9080 0000000000000000 0000000100000005
raw: ffffea00024defe0 ffffea00027779e0 ffff8880b1bbf800 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a34c9680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a34c9700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a34c9780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880a34c9800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a34c9880: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
==================================================================


---
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,
Jan 22, 2023, 5:35:38 PM1/22/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 97205fccccdc Linux 4.14.303
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=101f6951480000
kernel config: https://syzkaller.appspot.com/x/.config?x=9082325d51b8e29e
dashboard link: https://syzkaller.appspot.com/bug?extid=f632f1268ced221d14f2
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1190b061480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1261e256480000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/743935faa88a/disk-97205fcc.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/c24286de77a6/vmlinux-97205fcc.xz
kernel image: https://storage.googleapis.com/syzbot-assets/a69348a09157/bzImage-97205fcc.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/6aeb6e8690d3/mount_0.gz

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

syz-executor303 (13908): drop_caches: 2
syz-executor303 (13879): drop_caches: 2
syz-executor303 (13868): drop_caches: 2
XFS (loop5): Unmounting Filesystem
==================================================================
BUG: KASAN: use-after-free in list_sort.part.0+0x693/0x6d0 lib/list_sort.c:117
Write of size 8 at addr ffff8880b4aad148 by task syz-executor303/13894

CPU: 1 PID: 13894 Comm: syz-executor303 Not tainted 4.14.303-syzkaller #0
RIP: 0033:0x7f2ba5c6ff8a
RSP: 002b:00007ffc14f50a28 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00646975756f6e2c RCX: 00007f2ba5c6ff8a
RDX: 000000002000bb00 RSI: 0000000020000040 RDI: 00007ffc14f50a40
RBP: 00007ffc14f50a40 R08: 00007ffc14f50a80 R09: 000000000000bae7
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000004
R13: 0000555556f452c0 R14: 0000000000000000 R15: 00007ffc14f50a80

Allocated by task 13894:
Freed by task 13868:
The buggy address belongs to the object at ffff8880b4aad040
which belongs to the cache xfs_buf of size 584
The buggy address is located 264 bytes inside of
584-byte region [ffff8880b4aad040, ffff8880b4aad288)
The buggy address belongs to the page:
page:ffffea0002d2ab40 count:1 mapcount:0 mapping:ffff8880b4aad040 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff8880b4aad040 0000000000000000 0000000100000005
raw: ffffea000273cde0 ffffea000286bfa0 ffff8880b0c03000 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880b4aad000: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff8880b4aad080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880b4aad100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880b4aad180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880b4aad200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
syz-executor303 (13908): drop_caches: 2
XFS (loop0): Unmounting Filesystem
XFS (loop1): Unmounting Filesystem

Reply all
Reply to author
Forward
0 new messages