[ext4?] KASAN: use-after-free Read in ext4_find_extent

10 views
Skip to first unread message

syzbot

unread,
Dec 26, 2022, 2:59:45 AM12/26/22
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 003c389455eb Merge 5.10.160 into android12-5.10-lts
git tree: android12-5.10-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=14f9fd08480000
kernel config: https://syzkaller.appspot.com/x/.config?x=ce128396c79a61d9
dashboard link: https://syzkaller.appspot.com/bug?extid=212b805f83aa4e82c10a
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=1004109c480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1518d2ac480000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/722a669278a6/disk-003c3894.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f7a09169d423/vmlinux-003c3894.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4c5efdf62a59/bzImage-003c3894.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/b33b8c04d4f7/mount_0.gz

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

EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue
==================================================================
BUG: KASAN: use-after-free in ext4_ext_binsearch_idx fs/ext4/extents.c:758 [inline]
BUG: KASAN: use-after-free in ext4_find_extent+0x697/0xd80 fs/ext4/extents.c:923
Read of size 4 at addr ffff88810e7ae368 by task syz-executor281/371

CPU: 1 PID: 371 Comm: syz-executor281 Not tainted 5.10.160-syzkaller-01321-g003c389455eb #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_ext_binsearch_idx fs/ext4/extents.c:758 [inline]
ext4_find_extent+0x697/0xd80 fs/ext4/extents.c:923
ext4_clu_mapped+0xa0/0x7a0 fs/ext4/extents.c:5806
ext4_insert_delayed_block fs/ext4/inode.c:1697 [inline]
ext4_da_map_blocks fs/ext4/inode.c:1807 [inline]
ext4_da_get_block_prep+0x9f9/0x13d0 fs/ext4/inode.c:1871
__block_write_begin_int+0x6df/0x1800 fs/buffer.c:2039
__block_write_begin+0x30/0x40 fs/buffer.c:2089
ext4_da_convert_inline_data_to_extent+0x310/0x5c0 fs/ext4/inline.c:844
ext4_da_write_inline_data_begin+0x23b/0x750 fs/ext4/inline.c:917
ext4_da_write_begin+0x532/0xf10 fs/ext4/inode.c:3039
generic_perform_write+0x309/0x5b0 mm/filemap.c:3468
ext4_buffered_write_iter+0x47c/0x610 fs/ext4/file.c:272
ext4_file_write_iter+0x192/0x1c70 fs/ext4/file.c:689
call_write_iter include/linux/fs.h:1969 [inline]
new_sync_write fs/read_write.c:518 [inline]
vfs_write+0xc4a/0xf80 fs/read_write.c:605
ksys_write+0x198/0x2c0 fs/read_write.c:658
__do_sys_write fs/read_write.c:670 [inline]
__se_sys_write fs/read_write.c:667 [inline]
__x64_sys_write+0x7b/0x90 fs/read_write.c:667
do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f655525e7b9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 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:00007ffe5faa6898 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f655525e7b9
RDX: 00000000175d9003 RSI: 0000000020000200 RDI: 0000000000000004
RBP: 00007f655521e050 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000079f R11: 0000000000000246 R12: 00007f655521e0e0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 296:
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
proc_alloc_inode+0x1d/0xb0 fs/proc/inode.c:69
alloc_inode fs/inode.c:233 [inline]
new_inode_pseudo+0x64/0x220 fs/inode.c:929
new_inode+0x28/0x1c0 fs/inode.c:958
proc_pid_make_inode+0x27/0x2f0 fs/proc/base.c:1894
proc_pid_instantiate+0x4c/0x1a0 fs/proc/base.c:3348
proc_pid_lookup+0x196/0x270 fs/proc/base.c:3391
proc_root_lookup+0x22/0x50 fs/proc/root.c:321
__lookup_slow+0x2b3/0x400 fs/namei.c:1630
lookup_slow+0x5a/0x80 fs/namei.c:1647
walk_component+0x425/0x5a0 fs/namei.c:1942
link_path_walk+0x5e7/0xc40 fs/namei.c:2261
path_openat+0x264/0x2fd0 fs/namei.c:3444
do_filp_open+0x200/0x440 fs/namei.c:3475
do_sys_openat2+0x13b/0x470 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_64+0x34/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x61/0xc6

Freed by task 143:
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
proc_free_inode+0x1d/0x20 fs/proc/inode.c:85
i_callback+0x4b/0x70 fs/inode.c:222
rcu_do_batch+0x59e/0xc40 kernel/rcu/tree.c:2485
rcu_core+0x59b/0xe30 kernel/rcu/tree.c:2726
rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2739
__do_softirq+0x27e/0x596 kernel/softirq.c:305

Last potentially related work creation:
kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
kasan_record_aux_stack+0xca/0xf0 mm/kasan/generic.c:345
__call_rcu kernel/rcu/tree.c:2967 [inline]
call_rcu+0x140/0x1300 kernel/rcu/tree.c:3041
destroy_inode fs/inode.c:288 [inline]
evict+0x646/0x6c0 fs/inode.c:594
iput_final fs/inode.c:1655 [inline]
iput+0x61f/0x7d0 fs/inode.c:1681
dentry_unlink_inode+0x2df/0x3d0 fs/dcache.c:374
__dentry_kill+0x3e2/0x5d0 fs/dcache.c:579
dentry_kill+0xc0/0x2a0 fs/dcache.c:692
dput+0x175/0x320 fs/dcache.c:878
proc_invalidate_siblings_dcache+0x2c1/0x410 fs/proc/inode.c:151
proc_flush_pid+0x1a/0x20 fs/proc/base.c:3340
release_task+0x10d6/0x1340 kernel/exit.c:223
wait_task_zombie kernel/exit.c:1095 [inline]
wait_consider_task+0x18a2/0x2970 kernel/exit.c:1322
do_wait_thread kernel/exit.c:1385 [inline]
do_wait+0x2f1/0x810 kernel/exit.c:1456
kernel_wait4+0x29c/0x3c0 kernel/exit.c:1618
__do_sys_wait4 kernel/exit.c:1646 [inline]
__se_sys_wait4 kernel/exit.c:1642 [inline]
__x64_sys_wait4+0x130/0x1e0 kernel/exit.c:1642
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 ffff88810e7ae350
which belongs to the cache proc_inode_cache of size 776
The buggy address is located 24 bytes inside of
776-byte region [ffff88810e7ae350, ffff88810e7ae658)
The buggy address belongs to the page:
page:ffffea000439eb00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10e7ac
head:ffffea000439eb00 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff88810017f980
raw: 0000000000000000 0000000000120012 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Reclaimable, gfp_mask 0xd20d0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_RECLAIMABLE), pid 293, ts 11702775924, free_ts 0
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
proc_alloc_inode+0x1d/0xb0 fs/proc/inode.c:69
alloc_inode fs/inode.c:233 [inline]
new_inode_pseudo+0x64/0x220 fs/inode.c:929
new_inode+0x28/0x1c0 fs/inode.c:958
proc_pid_make_inode+0x27/0x2f0 fs/proc/base.c:1894
proc_pident_instantiate+0x75/0x2f0 fs/proc/base.c:2607
proc_pident_lookup fs/proc/base.c:2643 [inline]
proc_tgid_base_lookup+0x1a5/0x250 fs/proc/base.c:3307
lookup_open fs/namei.c:3164 [inline]
open_last_lookups fs/namei.c:3255 [inline]
path_openat+0x119a/0x2fd0 fs/namei.c:3445
do_filp_open+0x200/0x440 fs/namei.c:3475
do_sys_openat2+0x13b/0x470 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
page_owner free stack trace missing

Memory state around the buggy address:
ffff88810e7ae200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88810e7ae280: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc
>ffff88810e7ae300: fc fc fc fc fc fc fc fc fc fc fa fb fb fb fb fb
^
ffff88810e7ae380: fb fb fb fb fb fb fb fb fb fb f


---
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

syzbot

unread,
Dec 26, 2022, 2:59:46 AM12/26/22
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c73b4619ad86 ANDROID: abi preservation for fscrypt change ..
git tree: android13-5.15-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=15acc04c480000
kernel config: https://syzkaller.appspot.com/x/.config?x=d7c9bd3bb9661aad
dashboard link: https://syzkaller.appspot.com/bug?extid=0827b4b52b5ebf65f219
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=13f634a8480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17beb560480000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d4a785f6c196/disk-c73b4619.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/e2fba875c9ab/vmlinux-c73b4619.xz
kernel image: https://storage.googleapis.com/syzbot-assets/a870e2543ec9/bzImage-c73b4619.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/26c97fdd9475/mount_0.gz

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

==================================================================
BUG: KASAN: use-after-free in ext4_ext_binsearch_idx fs/ext4/extents.c:759 [inline]
BUG: KASAN: use-after-free in ext4_find_extent+0x697/0xd80 fs/ext4/extents.c:924
Read of size 4 at addr ffff88810979e268 by task syz-executor202/407

CPU: 1 PID: 407 Comm: syz-executor202 Not tainted 5.15.78-syzkaller-00911-gc73b4619ad86 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
print_address_description+0x87/0x3d0 mm/kasan/report.c:256
__kasan_report mm/kasan/report.c:435 [inline]
kasan_report+0x1a6/0x1f0 mm/kasan/report.c:452
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308
ext4_ext_binsearch_idx fs/ext4/extents.c:759 [inline]
ext4_find_extent+0x697/0xd80 fs/ext4/extents.c:924
ext4_clu_mapped+0xbb/0x950 fs/ext4/extents.c:5806
ext4_insert_delayed_block fs/ext4/inode.c:1683 [inline]
ext4_da_map_blocks fs/ext4/inode.c:1793 [inline]
ext4_da_get_block_prep+0xa16/0x1410 fs/ext4/inode.c:1857
__block_write_begin_int+0x6ae/0x17a0 fs/buffer.c:2012
__block_write_begin+0x30/0x40 fs/buffer.c:2062
ext4_da_convert_inline_data_to_extent fs/ext4/inline.c:892 [inline]
ext4_da_write_inline_data_begin+0x4ff/0xc70 fs/ext4/inline.c:965
ext4_da_write_begin+0x533/0xbf0 fs/ext4/inode.c:2996
generic_perform_write+0x2cd/0x5d0 mm/filemap.c:3825
ext4_buffered_write_iter+0x49b/0x630 fs/ext4/file.c:271
ext4_file_write_iter+0x448/0x1cc0
call_write_iter include/linux/fs.h:2138 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0xc8d/0x1050 fs/read_write.c:594
ksys_write+0x198/0x2c0 fs/read_write.c:647
__do_sys_write fs/read_write.c:659 [inline]
__se_sys_write fs/read_write.c:656 [inline]
__x64_sys_write+0x7b/0x90 fs/read_write.c:656
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fad587067b9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 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:00007fff754e6698 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fad587067b9
RDX: 00000000175d9003 RSI: 0000000020000200 RDI: 0000000000000004
RBP: 00007fad586c6050 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000079f R11: 0000000000000246 R12: 00007fad586c60e0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>

The buggy address belongs to the page:
page:ffffea000425e780 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10979e
flags: 0x4000000000000000(zone=1)
raw: 4000000000000000 ffffea000425e788 ffffea000425e788 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner info is not present (never set?)

Memory state around the buggy address:
ffff88810979e100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88810979e180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88810979e200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88810979e280: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
Reply all
Reply to author
Forward
0 new messages