KASAN: use-after-free Read in ext4_rename_dir_prepare

1 view
Skip to first unread message

syzbot

unread,
Nov 18, 2022, 4:08:34 AM11/18/22
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6b31c548a114 ANDROID: fix up struct sk_buf ABI breakage
git tree: android12-5.10-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=112e669e880000
kernel config: https://syzkaller.appspot.com/x/.config?x=6d89bc022a58ac9
dashboard link: https://syzkaller.appspot.com/bug?extid=a07b88e6427ec1c97aa5
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14ab4cd9880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10d1efc1880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/a48aa53de057/disk-6b31c548.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/cbb957f55a54/vmlinux-6b31c548.xz
kernel image: https://storage.googleapis.com/syzbot-assets/47843b37f0d4/bzImage-6b31c548.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/7047b199129b/mount_0.gz

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

==================================================================
BUG: KASAN: use-after-free in ext4_rename_dir_prepare+0x42e/0x4a0 fs/ext4/namei.c:3696
Read of size 4 at addr ffff8881025f0e02 by task syz-executor419/373

CPU: 0 PID: 373 Comm: syz-executor419 Not tainted 5.10.150-syzkaller-00396-g6b31c548a114 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
print_address_description+0x81/0x3c0 mm/kasan/report.c:233
__kasan_report mm/kasan/report.c:419 [inline]
kasan_report+0x1a4/0x1f0 mm/kasan/report.c:436
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308
ext4_rename_dir_prepare+0x42e/0x4a0 fs/ext4/namei.c:3696
ext4_cross_rename fs/ext4/namei.c:4204 [inline]
ext4_rename2+0x1f37/0x45a0 fs/ext4/namei.c:4288
vfs_rename+0x95e/0xde0 fs/namei.c:4389
do_renameat2+0x83e/0x1190 fs/namei.c:4536
__do_sys_renameat2 fs/namei.c:4571 [inline]
__se_sys_renameat2 fs/namei.c:4568 [inline]
__x64_sys_renameat2+0xbf/0xd0 fs/namei.c:4568
do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f1442ba96f9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd85d268b8 EFLAGS: 00000246 ORIG_RAX: 000000000000013c
RAX: ffffffffffffffda RBX: 00007f1442beeec8 RCX: 00007f1442ba96f9
RDX: 00000000ffffff9c RSI: 00000000200004c0 RDI: 0000000000000003
RBP: 0000000000000000 R08: 0000000000000002 R09: 00007ffd85d268e0
R10: 0000000020000000 R11: 0000000000000246 R12: 00007f1442b68590
R13: 00007ffd85d26910 R14: 00007ffd85d268f0 R15: 0000000000000000

Allocated by task 372:
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:428 [inline]
__kasan_slab_alloc+0xb2/0xe0 mm/kasan/common.c:461
kasan_slab_alloc include/linux/kasan.h:259 [inline]
slab_post_alloc_hook include/../mm/slab.h:583 [inline]
slab_alloc_node mm/slub.c:2956 [inline]
slab_alloc mm/slub.c:2964 [inline]
kmem_cache_alloc+0x16c/0x300 mm/slub.c:2969
mempool_alloc_slab+0x1d/0x30 mm/mempool.c:513
mempool_alloc+0x135/0x530 mm/mempool.c:393
bio_alloc_bioset+0x1db/0x650 block/bio.c:486
bio_alloc include/linux/bio.h:407 [inline]
mpage_alloc fs/mpage.c:115 [inline]
do_mpage_readpage+0x14e6/0x1b50 fs/mpage.c:342
mpage_readahead+0x2d5/0x5f0 fs/mpage.c:427
blkdev_readahead+0x1c/0x20 fs/block_dev.c:651
read_pages+0x160/0xb60 mm/readahead.c:140
page_cache_ra_unbounded+0x6d0/0x8b0 mm/readahead.c:248
do_page_cache_ra mm/readahead.c:277 [inline]
force_page_cache_ra+0x3e6/0x440 mm/readahead.c:308
page_cache_sync_ra+0x253/0x2c0 mm/readahead.c:584
page_cache_sync_readahead include/linux/pagemap.h:837 [inline]
generic_file_buffered_read+0x65f/0x2850 mm/filemap.c:2247
generic_file_read_iter+0x106/0x6d0 mm/filemap.c:2565
blkdev_read_iter+0x135/0x190 fs/block_dev.c:1954
call_read_iter include/linux/fs.h:1946 [inline]
new_sync_read fs/read_write.c:415 [inline]
vfs_read+0x9e2/0xbf0 fs/read_write.c:496
ksys_read+0x198/0x2c0 fs/read_write.c:634
__do_sys_read fs/read_write.c:644 [inline]
__se_sys_read fs/read_write.c:642 [inline]
__x64_sys_read+0x7b/0x90 fs/read_write.c:642
do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x61/0xc6

Freed by task 12:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357
____kasan_slab_free+0x121/0x160 mm/kasan/common.c:360
__kasan_slab_free+0x11/0x20 mm/kasan/common.c:368
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:1604 [inline]
slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1630
slab_free mm/slub.c:3212 [inline]
kmem_cache_free+0xa9/0x1f0 mm/slub.c:3228
mempool_free_slab+0x1d/0x30 mm/mempool.c:520
mempool_free+0xd5/0x310 mm/mempool.c:502
bio_put+0x34e/0x420 block/bio.c:266
mpage_end_io+0x325/0x5b0 fs/mpage.c:76
bio_endio+0x465/0x5c0 block/bio.c:1459
req_bio_endio block/blk-core.c:269 [inline]
blk_update_request+0x6d5/0x1250 block/blk-core.c:1471
blk_mq_end_request+0x42/0x80 block/blk-mq.c:568
lo_complete_rq+0x151/0x2e0 drivers/block/loop.c:488
blk_done_softirq+0x372/0x410 block/blk-mq.c:592
__do_softirq+0x27e/0x596 kernel/softirq.c:305

The buggy address belongs to the object at ffff8881025f0dc0
which belongs to the cache bio-0 of size 216
The buggy address is located 66 bytes inside of
216-byte region [ffff8881025f0dc0, ffff8881025f0e98)
The buggy address belongs to the page:
page:ffffea0004097c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1025f0
flags: 0x8000000000000200(slab)
raw: 8000000000000200 dead000000000100 dead000000000122 ffff888107fe8c00
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 0x92880(GFP_NOWAIT|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_NOMEMALLOC), pid 372, ts 19954386757, free_ts 19891007038
set_page_owner include/linux/page_owner.h:35 [inline]
post_alloc_hook mm/page_alloc.c:2386 [inline]
prep_new_page mm/page_alloc.c:2392 [inline]
get_page_from_freelist+0x755/0x810 mm/page_alloc.c:4073
__alloc_pages_nodemask+0x3b6/0x890 mm/page_alloc.c:5160
alloc_slab_page mm/slub.c:1815 [inline]
allocate_slab+0x78/0x540 mm/slub.c:1817
new_slab mm/slub.c:1878 [inline]
new_slab_objects mm/slub.c:2636 [inline]
___slab_alloc+0x131/0x2e0 mm/slub.c:2800
__slab_alloc+0x63/0xa0 mm/slub.c:2840
slab_alloc_node mm/slub.c:2922 [inline]
slab_alloc mm/slub.c:2964 [inline]
kmem_cache_alloc+0x1ef/0x300 mm/slub.c:2969
mempool_alloc_slab+0x1d/0x30 mm/mempool.c:513
mempool_alloc+0x135/0x530 mm/mempool.c:393
bio_alloc_bioset+0x1db/0x650 block/bio.c:486
bio_alloc include/linux/bio.h:407 [inline]
mpage_alloc fs/mpage.c:115 [inline]
do_mpage_readpage+0x14e6/0x1b50 fs/mpage.c:342
mpage_readahead+0x2d5/0x5f0 fs/mpage.c:427
blkdev_readahead+0x1c/0x20 fs/block_dev.c:651
read_pages+0x160/0xb60 mm/readahead.c:140
page_cache_ra_unbounded+0x6d0/0x8b0 mm/readahead.c:248
do_page_cache_ra mm/readahead.c:277 [inline]
force_page_cache_ra+0x3e6/0x440 mm/readahead.c:308
page_cache_sync_ra+0x253/0x2c0 mm/readahead.c:584
page last free stack trace:
reset_page_owner include/linux/page_owner.h:28 [inline]
free_pages_prepare mm/page_alloc.c:1332 [inline]
free_pcp_prepare+0x18c/0x1c0 mm/page_alloc.c:1406
free_unref_page_prepare mm/page_alloc.c:3293 [inline]
free_unref_page_list+0x11d/0x660 mm/page_alloc.c:3367
release_pages+0xc24/0xc60 mm/swap.c:1082
__pagevec_release+0x81/0xf0 mm/swap.c:1102
pagevec_release include/linux/pagevec.h:88 [inline]
truncate_inode_pages_range+0x9f8/0x1940 mm/truncate.c:367
truncate_inode_pages+0x24/0x30 mm/truncate.c:473
kill_bdev fs/block_dev.c:86 [inline]
set_blocksize+0x36e/0x3e0 fs/block_dev.c:171
sb_set_blocksize fs/block_dev.c:180 [inline]
sb_min_blocksize+0x101/0x1e0 fs/block_dev.c:196
ext4_fill_super+0x757/0x9150 fs/ext4/super.c:4075
mount_bdev+0x25f/0x370 fs/super.c:1419
ext4_mount+0x34/0x40 fs/ext4/super.c:6606
legacy_get_tree+0xf0/0x190 fs/fs_context.c:592
vfs_get_tree+0x88/0x290 fs/super.c:1549
do_new_mount+0x289/0xad0 fs/namespace.c:2899
path_mount+0x58d/0xce0 fs/namespace.c:3229
do_mount fs/namespace.c:3242 [inline]
__do_sys_mount fs/namespace.c:3450 [inline]
__se_sys_mount+0x2d2/0x3c0 fs/namespace.c:3427

Memory state around the buggy address:
ffff8881025f0d00: fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc
ffff8881025f0d80: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
>ffff8881025f0e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881025f0e80: fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8881025f0f00: fc fc fc fc fc fc fc fc fc 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 can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages