[v5.15] KASAN: use-after-free Read in xfs_iflush_cluster

2 views
Skip to first unread message

syzbot

unread,
Mar 13, 2023, 10:32:55 AM3/13/23
to syzkaller...@googlegroups.com
Hello,

syzbot found 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=15f1cf24c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=fec083380faceb1e
dashboard link: https://syzkaller.appspot.com/bug?extid=e1bb205b7aebac1da91f
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2

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

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

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

==================================================================
BUG: KASAN: use-after-free in xfs_iflush_cluster+0xad/0x12a0
Read of size 8 at addr ffff88804c31a410 by task xfsaild/loop2/6846

CPU: 0 PID: 6846 Comm: xfsaild/loop2 Not tainted 5.15.102-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
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
xfs_iflush_cluster+0xad/0x12a0
xfs_inode_item_push+0x1cd/0x2c0 fs/xfs/xfs_inode_item.c:567
xfsaild_push_item fs/xfs/xfs_trans_ail.c:414 [inline]
xfsaild_push fs/xfs/xfs_trans_ail.c:472 [inline]
xfsaild+0xd70/0x2ce0 fs/xfs/xfs_trans_ail.c:657
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 <unknown>:298
</TASK>

Allocated by task 6847:
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_inode_item_init+0x2f/0xc0 fs/xfs/xfs_inode_item.c:675
xfs_trans_ijoin+0xb6/0xe0 fs/xfs/libxfs/xfs_trans_inode.c:36
xfs_init_new_inode+0xd8c/0x1100 fs/xfs/xfs_inode.c:918
xfs_create+0xc7d/0x14a0 fs/xfs/xfs_inode.c:1044
xfs_generic_create+0x426/0xd70 fs/xfs/xfs_iops.c:197
lookup_open fs/namei.c:3334 [inline]
open_last_lookups fs/namei.c:3404 [inline]
path_openat+0x12c0/0x2ee0 fs/namei.c:3612
do_filp_open+0x21c/0x460 fs/namei.c:3642
do_sys_openat2+0x13b/0x500 fs/open.c:1211
do_sys_open fs/open.c:1227 [inline]
__do_sys_openat fs/open.c:1243 [inline]
__se_sys_openat fs/open.c:1238 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1238
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

Freed by task 6860:
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_inode_free_callback+0x1bd/0x230 fs/xfs/xfs_icache.c:142
rcu_do_batch kernel/rcu/tree.c:2509 [inline]
rcu_core+0xa15/0x1650 kernel/rcu/tree.c:2749
__do_softirq+0x3da/0xa10 kernel/softirq.c:558

The buggy address belongs to the object at ffff88804c31a3c0
which belongs to the cache xfs_ili of size 256
The buggy address is located 80 bytes inside of
256-byte region [ffff88804c31a3c0, ffff88804c31a4c0)
The buggy address belongs to the page:
page:ffffea000130c680 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88804c31a500 pfn:0x4c31a
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff888146884280
raw: ffff88804c31a500 00000000800c0006 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Reclaimable, gfp_mask 0x112c50(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 4533, ts 160390422041, free_ts 12790952450
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_inode_item_init+0x2f/0xc0 fs/xfs/xfs_inode_item.c:675
xfs_trans_ijoin+0xb6/0xe0 fs/xfs/libxfs/xfs_trans_inode.c:36
xfs_init_new_inode+0xd8c/0x1100 fs/xfs/xfs_inode.c:918
xfs_qm_qino_alloc+0x516/0x9c0 fs/xfs/xfs_qm.c:790
xfs_qm_init_quotainos+0x657/0x8a0 fs/xfs/xfs_qm.c:1552
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
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
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+0x95/0x2d0 mm/page_alloc.c:3396
free_contig_range+0x95/0xf0 mm/page_alloc.c:9321
destroy_args+0xfe/0x97f mm/debug_vm_pgtable.c:1018
debug_vm_pgtable+0x40d/0x462 mm/debug_vm_pgtable.c:1331
do_one_initcall+0x293/0x930 init/main.c:1306
do_initcall_level+0x157/0x207 init/main.c:1379
do_initcalls+0x49/0x86 init/main.c:1395
kernel_init_freeable+0x43c/0x5c5 init/main.c:1619
kernel_init+0x19/0x290 init/main.c:1510
ret_from_fork+0x1f/0x30 <unknown>:298

Memory state around the buggy address:
ffff88804c31a300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88804c31a380: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
>ffff88804c31a400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88804c31a480: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88804c31a500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
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 31, 2023, 1:05:45 PM3/31/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: c957cbb87315 Linux 5.15.105
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=11f363d1c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=6f83fab0469f5de7
dashboard link: https://syzkaller.appspot.com/bug?extid=e1bb205b7aebac1da91f
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=104a64edc80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11a1b6e1c80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/35817fda76e5/disk-c957cbb8.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/80f96399b8d4/vmlinux-c957cbb8.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4336a6ad59ec/bzImage-c957cbb8.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/7057a390c473/mount_0.gz

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

==================================================================
BUG: KASAN: use-after-free in xfs_iflush_cluster+0xcb/0x12a0 fs/xfs/xfs_inode.c:3645
Read of size 8 at addr ffff88807321e450 by task xfsaild/loop3/12189

CPU: 0 PID: 12189 Comm: xfsaild/loop3 Not tainted 5.15.105-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
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
xfs_iflush_cluster+0xcb/0x12a0 fs/xfs/xfs_inode.c:3645
xfs_inode_item_push+0x1cd/0x2c0 fs/xfs/xfs_inode_item.c:567
xfsaild_push_item fs/xfs/xfs_trans_ail.c:414 [inline]
xfsaild_push fs/xfs/xfs_trans_ail.c:472 [inline]
xfsaild+0xd6d/0x2970 fs/xfs/xfs_trans_ail.c:657
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
</TASK>

Allocated by task 12145:
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/0x280 mm/slub.c:3233
kmem_cache_zalloc include/linux/slab.h:711 [inline]
xfs_inode_item_init+0x2f/0xc0 fs/xfs/xfs_inode_item.c:675
xfs_trans_ijoin+0xb6/0xe0 fs/xfs/libxfs/xfs_trans_inode.c:36
xfs_create+0xbca/0x1370 fs/xfs/xfs_inode.c:1056
xfs_generic_create+0x426/0xd70 fs/xfs/xfs_iops.c:197
lookup_open fs/namei.c:3392 [inline]
open_last_lookups fs/namei.c:3462 [inline]
path_openat+0x12f6/0x2f20 fs/namei.c:3669
do_filp_open+0x21c/0x460 fs/namei.c:3699
do_sys_openat2+0x13b/0x500 fs/open.c:1211
do_sys_open fs/open.c:1227 [inline]
__do_sys_open fs/open.c:1235 [inline]
__se_sys_open fs/open.c:1231 [inline]
__x64_sys_open+0x221/0x270 fs/open.c:1231
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

Freed by task 20:
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/0x1f0 mm/slub.c:3515
xfs_inode_free_callback+0x1bd/0x230 fs/xfs/xfs_icache.c:142
rcu_do_batch kernel/rcu/tree.c:2509 [inline]
rcu_core+0xa15/0x1650 kernel/rcu/tree.c:2749
__do_softirq+0x3b3/0x93a kernel/softirq.c:558

The buggy address belongs to the object at ffff88807321e3c0
which belongs to the cache xfs_ili of size 256
The buggy address is located 144 bytes inside of
256-byte region [ffff88807321e3c0, ffff88807321e4c0)
The buggy address belongs to the page:
page:ffffea0001cc8780 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7321e
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0001cca1c0 0000000400000004 ffff8881467b83c0
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 Reclaimable, gfp_mask 0x12c50(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_RECLAIMABLE), pid 932, ts 970589278647, free_ts 827775611197
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
__alloc_pages+0x272/0x700 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+0x18e/0x280 mm/slub.c:3233
kmem_cache_zalloc include/linux/slab.h:711 [inline]
xfs_inode_item_init+0x2f/0xc0 fs/xfs/xfs_inode_item.c:675
xfs_trans_ijoin+0xb6/0xe0 fs/xfs/libxfs/xfs_trans_inode.c:36
xfs_fs_dirty_inode+0x1b4/0x250 fs/xfs/xfs_super.c:665
__mark_inode_dirty+0x2fd/0xd60 fs/fs-writeback.c:2439
mark_inode_dirty_sync include/linux/fs.h:2398 [inline]
__writeback_single_inode+0x3b2/0xe30 fs/fs-writeback.c:1647
writeback_sb_inodes+0xbf0/0x1a50 fs/fs-writeback.c:1905
wb_writeback+0x451/0xc50 fs/fs-writeback.c:2079
wb_do_writeback fs/fs-writeback.c:2222 [inline]
wb_workfn+0x46c/0x1130 fs/fs-writeback.c:2263
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2306
worker_thread+0xaca/0x1280 kernel/workqueue.c:2453
kthread+0x3f6/0x4f0 kernel/kthread.c:319
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+0xc34/0xcf0 mm/page_alloc.c:3317
free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
free_slab mm/slub.c:2015 [inline]
discard_slab mm/slub.c:2021 [inline]
__unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
do_slab_free mm/slub.c:3487 [inline]
___cache_free+0xe3/0x100 mm/slub.c:3506
qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
__kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
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/0x280 mm/slub.c:3233
getname_flags+0xb8/0x4e0 fs/namei.c:138
user_path_at_empty+0x2a/0x180 fs/namei.c:2852
user_path_at include/linux/namei.h:57 [inline]
vfs_statx+0x106/0x3b0 fs/stat.c:221
vfs_fstatat fs/stat.c:243 [inline]
__do_sys_newfstatat fs/stat.c:411 [inline]
__se_sys_newfstatat fs/stat.c:405 [inline]
__x64_sys_newfstatat+0x12c/0x1b0 fs/stat.c:405
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

Memory state around the buggy address:
ffff88807321e300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807321e380: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
>ffff88807321e400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807321e480: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88807321e500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

syzbot

unread,
Oct 14, 2023, 6:28:32 PM10/14/23
to syzkaller...@googlegroups.com
syzbot suspects this issue could be fixed by backporting the following commit:

commit 8027a9ad9b3568c5eb49c968ad6c97f279d76730
git tree: upstream
Author: Jiasheng Jiang <jias...@iscas.ac.cn>
Date: Wed Jan 5 07:47:29 2022 +0000

drm/imx: imx-ldb: Check for null pointer after calling kmemdup

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=16c3a1e5680000
kernel config: https://syzkaller.appspot.com/x/.config?x=a61e8195d8bdf36e
dashboard link: https://syzkaller.appspot.com/bug?extid=e1bb205b7aebac1da91f
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10daddf9280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14dce309280000


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