[Android 5.10] KASAN: use-after-free Read in ext4_rename_dir_prepare (3)

3 views
Skip to first unread message

syzbot

unread,
Apr 30, 2023, 7:52:43 AM4/30/23
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 416c4356f372 Merge 5.10.161 into android12-5.10-lts
git tree: android12-5.10-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=11633e1c280000
kernel config: https://syzkaller.appspot.com/x/.config?x=ba29236d2f217808
dashboard link: https://syzkaller.appspot.com/bug?extid=feecbbf039dd054a80e1
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=10f6deb4280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16b459d7c80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/0149809cf436/disk-416c4356.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2bf0b26aed77/vmlinux-416c4356.xz
kernel image: https://storage.googleapis.com/syzbot-assets/224b4978be5c/bzImage-416c4356.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/2b85fe60654f/mount_0.gz

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

ext4 filesystem being mounted at /root/syzkaller.uYsrAf/1/file0 supports timestamps until 2038 (0x7fffffff)
==================================================================
BUG: KASAN: use-after-free in ext4_rename_dir_prepare+0x42e/0x4a0 fs/ext4/namei.c:3704
Read of size 4 at addr ffff888119c14000 by task syz-executor122/376

CPU: 1 PID: 376 Comm: syz-executor122 Not tainted 5.10.161-syzkaller-00019-g416c4356f372 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023
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:3704
ext4_cross_rename fs/ext4/namei.c:4212 [inline]
ext4_rename2+0x1f37/0x45a0 fs/ext4/namei.c:4296
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:0x7f95898f4a29
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 90 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:00007ffcca6970d8 EFLAGS: 00000246 ORIG_RAX: 000000000000013c
RAX: ffffffffffffffda RBX: 0000000000005426 RCX: 00007f95898f4a29
RDX: 0000000000000004 RSI: 0000000020000080 RDI: 0000000000000005
RBP: 0000000000000000 R08: 0000000000000002 R09: 00007ffcca697100
R10: 00000000200000c0 R11: 0000000000000246 R12: 00007ffcca6970fc
R13: 00007ffcca697130 R14: 00007ffcca697110 R15: 0000000000000001

Allocated by task 345:
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
dup_mm+0x29/0x320 kernel/fork.c:1403
copy_mm+0x108/0x1b0 kernel/fork.c:1468
copy_process+0x133a/0x33a0 kernel/fork.c:2152
kernel_clone+0x22d/0x900 kernel/fork.c:2524
__do_sys_clone kernel/fork.c:2643 [inline]
__se_sys_clone kernel/fork.c:2627 [inline]
__x64_sys_clone+0x271/0x2e0 kernel/fork.c:2627
do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x61/0xc6

Freed by task 345:
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
__mmdrop+0x295/0x390 kernel/fork.c:722
mmdrop include/linux/sched/mm.h:49 [inline]
finish_task_switch+0x1e4/0x580 kernel/sched/core.c:3892
context_switch kernel/sched/core.c:4038 [inline]
__schedule+0x86e/0xc00 kernel/sched/core.c:4796
schedule+0x14b/0x1e0 kernel/sched/core.c:4874
pipe_read+0x9c8/0x1070 fs/pipe.c:378
call_read_iter include/linux/fs.h:1963 [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

The buggy address belongs to the object at ffff888119c14000
which belongs to the cache mm_struct of size 1104
The buggy address is located 0 bytes inside of
1104-byte region [ffff888119c14000, ffff888119c14450)
The buggy address belongs to the page:
page:ffffea0004670500 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x119c14
head:ffffea0004670500 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff888100066300
raw: 0000000000000000 00000000000c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 345, ts 16125248987, free_ts 16122080680
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
dup_mm+0x29/0x320 kernel/fork.c:1403
copy_mm+0x108/0x1b0 kernel/fork.c:1468
copy_process+0x133a/0x33a0 kernel/fork.c:2152
kernel_clone+0x22d/0x900 kernel/fork.c:2524
__do_sys_clone kernel/fork.c:2643 [inline]
__se_sys_clone kernel/fork.c:2627 [inline]
__x64_sys_clone+0x271/0x2e0 kernel/fork.c:2627
do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x61/0xc6
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_pages_ok+0x7f8/0x830 mm/page_alloc.c:1612
free_compound_page+0x72/0x90 mm/page_alloc.c:717
destroy_compound_page include/linux/mm.h:959 [inline]
__put_compound_page+0x72/0xb0 mm/swap.c:115
__put_page+0xc0/0xd0 mm/swap.c:131
put_page include/linux/mm.h:1255 [inline]
__skb_frag_unref include/linux/skbuff.h:3065 [inline]
skb_release_data+0x22d/0x630 net/core/skbuff.c:619
skb_release_all net/core/skbuff.c:680 [inline]
__kfree_skb+0x59/0x1c0 net/core/skbuff.c:694
sk_eat_skb include/net/sock.h:2599 [inline]
tcp_recvmsg+0x1637/0x35a0 net/ipv4/tcp.c:2317
inet_recvmsg+0x157/0x500 net/ipv4/af_inet.c:852
sock_recvmsg_nosec net/socket.c:886 [inline]
sock_recvmsg net/socket.c:904 [inline]
sock_read_iter+0x3a7/0x4d0 net/socket.c:977
call_read_iter include/linux/fs.h:1963 [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

Memory state around the buggy address:
ffff888119c13f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888119c13f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888119c14000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888119c14080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888119c14100: 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.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

Tudor Ambarus

unread,
May 8, 2023, 9:14:49 AM5/8/23
to syzbot+feecbb...@syzkaller.appspotmail.com, syzkaller-a...@googlegroups.com, Lee Jones
#syz fix: BACKPORT: ext4: fix use-after-free in ext4_rename_dir_prepare
Reply all
Reply to author
Forward
0 new messages