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

13 views
Skip to first unread message

syzbot

unread,
Jan 21, 2023, 9:06:45 AM1/21/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=14130d71480000
kernel config: https://syzkaller.appspot.com/x/.config?x=ba29236d2f217808
dashboard link: https://syzkaller.appspot.com/bug?extid=3ea2b85f9c3f27b8399f
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=178ebd7a480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14de9499480000

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/e0fef99154be/mount_0.gz

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

==================================================================
BUG: KASAN: use-after-free in ext4_ext_rm_leaf+0x153c/0x18c0 fs/ext4/extents.c:2614
Read of size 4 at addr ffff88811f789ff4 by task syz-executor399/4162

CPU: 0 PID: 4162 Comm: syz-executor399 Not tainted 5.10.161-syzkaller-00019-g416c4356f372 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/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_ext_rm_leaf+0x153c/0x18c0 fs/ext4/extents.c:2614
ext4_ext_remove_space+0xf25/0x22a0 fs/ext4/extents.c:2952
ext4_ext_truncate+0x18a/0x210 fs/ext4/extents.c:4413
ext4_truncate+0xba0/0x1270 fs/ext4/inode.c:4356
ext4_setattr+0xf7b/0x17f0 fs/ext4/inode.c:5599
notify_change+0xb76/0xe10 fs/attr.c:338
do_truncate+0x1ea/0x2d0 fs/open.c:65
handle_truncate fs/namei.c:2991 [inline]
do_open fs/namei.c:3333 [inline]
path_openat+0x294e/0x2fd0 fs/namei.c:3448
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
RIP: 0033:0x7f64ff0b87f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 71 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f64f6d432f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f64ff13d7b0 RCX: 00007f64ff0b87f9
RDX: 000000000000275a RSI: 00000000200001c0 RDI: 00000000ffffff9c
RBP: 00007f64ff10a814 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: be734677a9d9a8be
R13: 0030656c69662f2e R14: 6f6f6c2f7665642f R15: 00007f64ff13d7b8

The buggy address belongs to the page:
page:ffffea00047de240 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11f789
flags: 0x8000000000000000()
raw: 8000000000000000 ffffea00047de248 ffffea00047de248 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:
ffff88811f789e80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88811f789f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88811f789f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88811f78a000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88811f78a080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================


---
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,
Jan 21, 2023, 9:33:49 AM1/21/23
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 72d681a01da5 Revert "net: use struct_group to copy ip/ipv6..
git tree: android13-5.15-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=14d07561480000
kernel config: https://syzkaller.appspot.com/x/.config?x=f4ba95ecf3958808
dashboard link: https://syzkaller.appspot.com/bug?extid=eaa12770098b5ebf8847
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=16caa461480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=178b26fe480000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/9121a81631c9/disk-72d681a0.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/e5b495231897/vmlinux-72d681a0.xz
kernel image: https://storage.googleapis.com/syzbot-assets/bbbaed45751a/bzImage-72d681a0.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/c1b8b6e3530e/mount_0.gz

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

==================================================================
BUG: KASAN: use-after-free in ext4_ext_rm_leaf+0x14d4/0x1800 fs/ext4/extents.c:2619
Read of size 4 at addr ffff888123a80ff4 by task syz-executor214/14902

CPU: 0 PID: 14902 Comm: syz-executor214 Not tainted 5.15.80-syzkaller-00318-g72d681a01da5 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
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_rm_leaf+0x14d4/0x1800 fs/ext4/extents.c:2619
ext4_ext_remove_space+0xfc5/0x21b0 fs/ext4/extents.c:2957
ext4_ext_truncate+0x19f/0x250 fs/ext4/extents.c:4419
ext4_truncate+0x942/0xf50 fs/ext4/inode.c:4268
ext4_setattr+0xfe4/0x1920 fs/ext4/inode.c:5529
notify_change+0xd8f/0x1040 fs/attr.c:426
do_truncate+0x214/0x300 fs/open.c:66
handle_truncate fs/namei.c:3136 [inline]
do_open fs/namei.c:3484 [inline]
path_openat+0x2849/0x2ea0 fs/namei.c:3615
do_filp_open+0x277/0x4f0 fs/namei.c:3642
do_sys_openat2+0x13b/0x500 fs/open.c:1234
do_sys_open fs/open.c:1250 [inline]
__do_sys_openat fs/open.c:1266 [inline]
__se_sys_openat fs/open.c:1261 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1261
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:0x7f1c3248a7f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 71 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f1c2a0f42f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f1c3250f7c0 RCX: 00007f1c3248a7f9
RDX: 000000000000275a RSI: 00000000200001c0 RDI: 00000000ffffff9c
RBP: 00007f1c324dc814 R08: 00007f1c2a0f4700 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: be734677a9d9a8be
R13: 0030656c69662f2e R14: 6f6f6c2f7665642f R15: 00007f1c3250f7c8
</TASK>

The buggy address belongs to the page:
page:ffffea00048ea000 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x123a80
flags: 0x4000000000000000(zone=1)
raw: 4000000000000000 ffffea0004950488 ffffea000496e388 0000000000000000
raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 0, migratetype Movable, gfp_mask 0x100cca(GFP_HIGHUSER_MOVABLE), pid 14254, ts 252534449862, free_ts 252822873974
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0x1ab/0x1b0 mm/page_alloc.c:2495
prep_new_page mm/page_alloc.c:2501 [inline]
get_page_from_freelist+0x38b/0x400 mm/page_alloc.c:4281
__alloc_pages+0x3a8/0x7c0 mm/page_alloc.c:5548
__alloc_pages_node include/linux/gfp.h:591 [inline]
alloc_pages_node include/linux/gfp.h:605 [inline]
alloc_pages include/linux/gfp.h:618 [inline]
shmem_alloc_page mm/shmem.c:1587 [inline]
shmem_alloc_and_acct_page+0x4a0/0xa20 mm/shmem.c:1612
shmem_getpage_gfp+0x1487/0x25f0 mm/shmem.c:1907
shmem_getpage mm/shmem.c:152 [inline]
shmem_write_begin+0xc8/0x1b0 mm/shmem.c:2478
generic_perform_write+0x2cd/0x5d0 mm/filemap.c:3825
__generic_file_write_iter+0x25b/0x4b0 mm/filemap.c:3952
generic_file_write_iter+0xaf/0x1c0 mm/filemap.c:3984
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
page last free stack trace:
reset_page_owner include/linux/page_owner.h:26 [inline]
free_pages_prepare mm/page_alloc.c:1364 [inline]
free_pcp_prepare+0x448/0x450 mm/page_alloc.c:1435
free_unref_page_prepare mm/page_alloc.c:3433 [inline]
free_unref_page_list+0x16a/0xad0 mm/page_alloc.c:3554
release_pages+0xf3e/0xf90 mm/swap.c:1010
__pagevec_release+0x81/0xf0 mm/swap.c:1030
pagevec_release include/linux/pagevec.h:81 [inline]
shmem_undo_range+0x64c/0x1c90 mm/shmem.c:965
shmem_truncate_range mm/shmem.c:1064 [inline]
shmem_evict_inode+0x228/0xa30 mm/shmem.c:1146
evict+0x2a3/0x630 fs/inode.c:587
iput_final fs/inode.c:1663 [inline]
iput+0x61c/0x7d0 fs/inode.c:1689
dentry_unlink_inode+0x349/0x430 fs/dcache.c:376
__dentry_kill+0x3e2/0x5d0 fs/dcache.c:582
dentry_kill+0xc0/0x2a0
dput+0x175/0x320 fs/dcache.c:888
__fput+0x65a/0x910 fs/file_table.c:288
____fput+0x15/0x20 fs/file_table.c:308
task_work_run+0x147/0x1b0 kernel/task_work.c:164
ptrace_notify+0x29a/0x340 kernel/signal.c:2382

Memory state around the buggy address:
ffff888123a80e80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888123a80f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888123a80f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff888123a81000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888123a81080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

syzbot

unread,
Feb 21, 2023, 1:55:42 PM2/21/23
to syzkaller-a...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 7192afa5e4bfa1316a3ad4875562e9b123af7c06
Author: Baokun Li <liba...@huawei.com>
Date: Wed Aug 17 13:27:01 2022 +0000

ext4: add inode table check in __ext4_get_inode_loc to aovid possible infinite loop

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12903844c80000
start commit: 72d681a01da5 Revert "net: use struct_group to copy ip/ipv6..
git tree: android13-5.15-lts
If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: ext4: add inode table check in __ext4_get_inode_loc to aovid possible infinite loop

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Tudor Ambarus

unread,
Feb 23, 2023, 4:20:20 AM2/23/23
to syzbot+eaa127...@syzkaller.appspotmail.com, jone...@google.com, syzkaller-a...@googlegroups.com

Tudor Ambarus

unread,
Feb 23, 2023, 4:21:20 AM2/23/23
to syzbot+3ea2b8...@syzkaller.appspotmail.com, jone...@google.com, syzkaller-a...@googlegroups.com

syzbot

unread,
May 24, 2023, 5:20:35 AM5/24/23
to jone...@google.com, syzkaller-a...@googlegroups.com, tudor....@linaro.org
This bug is marked as fixed by commit:
ext4: add inode table check in __ext4_get_inode_loc to aovid

But I can't find it in the tested trees[1] for more than 90 days.
Is it a correct commit? Please update it by replying:

#syz fix: exact-commit-title

Until then the bug is still considered open and new crashes with
the same signature are ignored.

Kernel: Android 5.15
Dashboard link: https://syzkaller.appspot.com/bug?extid=eaa12770098b5ebf8847

---
[1] I expect the commit to be present in:

1. android13-5.15-lts branch of
https://android.googlesource.com/kernel/common

syzbot

unread,
May 24, 2023, 5:21:36 AM5/24/23
to jone...@google.com, syzkaller-a...@googlegroups.com, tudor....@linaro.org
This bug is marked as fixed by commit:
ext4: add inode table check in __ext4_get_inode_loc to aovid

But I can't find it in the tested trees[1] for more than 90 days.
Is it a correct commit? Please update it by replying:

#syz fix: exact-commit-title

Until then the bug is still considered open and new crashes with
the same signature are ignored.

Kernel: Android 5.10
Dashboard link: https://syzkaller.appspot.com/bug?extid=3ea2b85f9c3f27b8399f

---
[1] I expect the commit to be present in:

1. android13-5.10-lts branch of
https://android.googlesource.com/kernel/common

Tudor Ambarus

unread,
May 24, 2023, 5:27:25 AM5/24/23
to syzbot, jone...@google.com, syzkaller-a...@googlegroups.com
#syz fix: ext4: add inode table check in __ext4_get_inode_loc to aovid
possible infinite loop

Tudor Ambarus

unread,
May 24, 2023, 5:35:04 AM5/24/23
to syzbot, jone...@google.com, syzkaller-a...@googlegroups.com
to wrap or not to wrap lines, ugh

#syz fix: ext4: add inode table check in __ext4_get_inode_loc to aovid possible infinite loop

On 5/24/23 10:21, syzbot wrote:

Tudor Ambarus

unread,
May 24, 2023, 5:35:26 AM5/24/23
to syzbot, jone...@google.com, syzkaller-a...@googlegroups.com
#syz fix: ext4: add inode table check in __ext4_get_inode_loc to aovid possible infinite loop

Reply all
Reply to author
Forward
0 new messages