[Android 5.15] KASAN: out-of-bounds Read in ext4_ext_remove_space

2 views
Skip to first unread message

syzbot

unread,
Aug 4, 2023, 6:38:57 PM8/4/23
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 748fd0d9ca0f Merge 26a0ba5d1654 ("Input: drv260x - sleep b..
git tree: android13-5.15-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=179bc625a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=477a93b6c99ec3fb
dashboard link: https://syzkaller.appspot.com/bug?extid=b08e3d059329c5bfbfdb
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14393f6da80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12976b83a80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/1e163294ea7b/disk-748fd0d9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/7923177c6547/vmlinux-748fd0d9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0919d1e9d0ac/bzImage-748fd0d9.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/c1edbd6984c9/mount_0.gz

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

==================================================================
BUG: KASAN: out-of-bounds in ext4_ext_rm_leaf fs/ext4/extents.c:2735 [inline]
BUG: KASAN: out-of-bounds in ext4_ext_remove_space+0x2149/0x4a60 fs/ext4/extents.c:2957
Read of size 18446744073709551544 at addr ffff88811aee3054 by task syz-executor347/307

CPU: 0 PID: 307 Comm: syz-executor347 Not tainted 5.15.120-syzkaller-00229-g748fd0d9ca0f #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/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/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:427 [inline]
kasan_report+0x179/0x1c0 mm/kasan/report.c:444
kasan_check_range+0x293/0x2a0 mm/kasan/generic.c:189
memmove+0x2d/0x70 mm/kasan/shadow.c:54
ext4_ext_rm_leaf fs/ext4/extents.c:2735 [inline]
ext4_ext_remove_space+0x2149/0x4a60 fs/ext4/extents.c:2957
ext4_punch_hole+0x794/0xbf0 fs/ext4/inode.c:4129
ext4_fallocate+0x30c/0x1f10 fs/ext4/extents.c:4711
vfs_fallocate+0x492/0x570 fs/open.c:309
do_vfs_ioctl+0x2238/0x2a80 fs/ioctl.c:853
__do_sys_ioctl fs/ioctl.c:872 [inline]
__se_sys_ioctl+0x99/0x190 fs/ioctl.c:860
__x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:860
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
RIP: 0033:0x7f9520578e19
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 18 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9518154218 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f95206006d8 RCX: 00007f9520578e19
RDX: 0000000020000080 RSI: 000000004030582b RDI: 0000000000000004
RBP: 00007f95206006d0 R08: 00007ffe005087d7 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f95205cd578
R13: 000000000000000b R14: 00007ffe005086f0 R15: 6f6f6c2f7665642f
</TASK>

The buggy address belongs to the page:
page:ffffea00046bb8c0 refcount:2 mapcount:0 mapping:ffff888109192c98 index:0x3a pfn:0x11aee3
memcg:ffff8881001f8000
aops:def_blk_aops ino:700000
flags: 0x4000000000002036(referenced|uptodate|lru|active|private|zone=1)
raw: 4000000000002036 ffffea00046da308 ffffea00046da408 ffff888109192c98
raw: 000000000000003a ffff88811bd1bb28 00000002ffffffff ffff8881001f8000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x108c48(GFP_NOFS|__GFP_NOFAIL|__GFP_HARDWALL|__GFP_MOVABLE), pid 304, ts 23868189950, free_ts 23787864920
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0x1a3/0x1b0 mm/page_alloc.c:2600
prep_new_page mm/page_alloc.c:2606 [inline]
get_page_from_freelist+0x2ed2/0x2f90 mm/page_alloc.c:4474
__alloc_pages+0x206/0x5e0 mm/page_alloc.c:5765
__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]
__page_cache_alloc include/linux/pagemap.h:305 [inline]
pagecache_get_page+0xb18/0xeb0 mm/filemap.c:1940
find_or_create_page include/linux/pagemap.h:418 [inline]
grow_dev_page fs/buffer.c:949 [inline]
grow_buffers fs/buffer.c:1014 [inline]
__getblk_slow fs/buffer.c:1041 [inline]
__getblk_gfp+0x21e/0x7c0 fs/buffer.c:1336
sb_getblk_gfp include/linux/buffer_head.h:368 [inline]
ext4_ext_grow_indepth fs/ext4/extents.c:1328 [inline]
ext4_ext_create_new_leaf fs/ext4/extents.c:1429 [inline]
ext4_ext_insert_extent+0xf7a/0x4b10 fs/ext4/extents.c:2099
ext4_ext_map_blocks+0x1c61/0x7250 fs/ext4/extents.c:4308
ext4_map_blocks+0xaa7/0x1e30 fs/ext4/inode.c:646
_ext4_get_block+0x23b/0x660 fs/ext4/inode.c:803
ext4_get_block+0x39/0x50 fs/ext4/inode.c:820
ext4_block_write_begin+0x5ea/0x12a0 fs/ext4/inode.c:1088
ext4_write_begin+0x6bc/0x13d0
ext4_da_write_begin+0x4a2/0xc30 fs/ext4/inode.c:2986
generic_perform_write+0x2bc/0x5a0 mm/filemap.c:3833
ext4_buffered_write_iter+0x48a/0x610 fs/ext4/file.c:270
ext4_file_write_iter+0x443/0x1c80
page last free stack trace:
reset_page_owner include/linux/page_owner.h:26 [inline]
free_pages_prepare mm/page_alloc.c:1467 [inline]
free_pcp_prepare mm/page_alloc.c:1539 [inline]
free_unref_page_prepare+0x7c8/0x7d0 mm/page_alloc.c:3523
free_unref_page_list+0x14b/0xa60 mm/page_alloc.c:3660
release_pages+0x1310/0x1370 mm/swap.c:1009
__pagevec_release+0x84/0x100 mm/swap.c:1029
pagevec_release include/linux/pagevec.h:81 [inline]
shmem_undo_range+0x604/0x1560 mm/shmem.c:965
shmem_truncate_range mm/shmem.c:1064 [inline]
shmem_evict_inode+0x215/0x9d0 mm/shmem.c:1146
evict+0x2a3/0x630 fs/inode.c:587
iput_final fs/inode.c:1663 [inline]
iput+0x63b/0x7e0 fs/inode.c:1689
dentry_unlink_inode+0x34f/0x440 fs/dcache.c:376
__dentry_kill+0x447/0x660 fs/dcache.c:582
dentry_kill+0xc0/0x2a0
dput+0x165/0x320 fs/dcache.c:888
__fput+0x662/0x910 fs/file_table.c:288
____fput+0x15/0x20 fs/file_table.c:308
task_work_run+0x129/0x190 kernel/task_work.c:164
ptrace_notify+0x29e/0x350 kernel/signal.c:2383

Memory state around the buggy address:
ffff88811aee2f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88811aee2f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88811aee3000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^
ffff88811aee3080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88811aee3100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
EXT4-fs error (device loop0): __ext4_get_inode_loc:4350: comm syz-executor347: Invalid inode table block 0 in block_group 0
EXT4-fs error (device loop0) in ext4_reserve_inode_write:5830: Corrupt filesystem
EXT4-fs error (device loop0): ext4_punch_hole:4142: inode #16: comm syz-executor347: mark_inode_dirty error


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

syzbot

unread,
Aug 14, 2023, 1:29:45 PM8/14/23
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: d7dacaa439c7 UPSTREAM: USB: Gadget: core: Help prevent pan..
git tree: android14-6.1
console+strace: https://syzkaller.appspot.com/x/log.txt?x=148f8553a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=c5b8b7a65c87c651
dashboard link: https://syzkaller.appspot.com/bug?extid=f0e6e46e2055146521a4
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1438c6f7a80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=101a069ba80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d10ac3387ed0/disk-d7dacaa4.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/3a02f4a42694/vmlinux-d7dacaa4.xz
kernel image: https://storage.googleapis.com/syzbot-assets/bbfa7dec77cc/bzImage-d7dacaa4.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/15bb0592111e/mount_0.gz

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

EXT4-fs error (device loop0): ext4_read_block_bitmap_nowait:438: comm syz-executor348: Invalid block bitmap block 0 in block_group 0
EXT4-fs (loop0): Remounting filesystem read-only
EXT4-fs error (device loop0) in ext4_mb_clear_bb:6077: Corrupt filesystem
==================================================================
BUG: KASAN: out-of-bounds in ext4_ext_rm_leaf fs/ext4/extents.c:2737 [inline]
BUG: KASAN: out-of-bounds in ext4_ext_remove_space+0x1e16/0x4f50 fs/ext4/extents.c:2959
Read of size 18446744073709551544 at addr ffff88812095e054 by task syz-executor348/311

CPU: 1 PID: 311 Comm: syz-executor348 Not tainted 6.1.25-syzkaller-00011-gd7dacaa439c7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/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 mm/kasan/report.c:316 [inline]
print_report+0x158/0x4e0 mm/kasan/report.c:427
kasan_report+0x13c/0x170 mm/kasan/report.c:531
kasan_check_range+0x294/0x2a0 mm/kasan/generic.c:189
memmove+0x2d/0x70 mm/kasan/shadow.c:54
ext4_ext_rm_leaf fs/ext4/extents.c:2737 [inline]
ext4_ext_remove_space+0x1e16/0x4f50 fs/ext4/extents.c:2959
ext4_punch_hole+0x794/0xc00 fs/ext4/inode.c:4124
ext4_fallocate+0x318/0x1e90 fs/ext4/extents.c:4708
vfs_fallocate+0x492/0x570 fs/open.c:324
do_vfs_ioctl+0x2150/0x29a0 fs/ioctl.c:849
__do_sys_ioctl fs/ioctl.c:868 [inline]
__se_sys_ioctl+0x99/0x190 fs/ioctl.c:856
__x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856
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+0x63/0xcd
RIP: 0033:0x7fa52c38be19
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 18 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fa523f67218 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fa52c4136d8 RCX: 00007fa52c38be19
RDX: 0000000020000080 RSI: 000000004030582b RDI: 0000000000000004
RBP: 00007fa52c4136d0 R08: 00007ffe5a02a957 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fa52c3e0578
R13: 000000000000000b R14: 00007ffe5a02a870 R15: 6f6f6c2f7665642f
</TASK>

The buggy address belongs to the physical page:
page:ffffea0004825780 refcount:2 mapcount:0 mapping:ffff88810b8e1c50 index:0x3a pfn:0x12095e
memcg:ffff88810031e000
aops:def_blk_aops ino:700000
flags: 0x4e00000000002056(referenced|uptodate|lru|workingset|private|zone=1)
raw: 4e00000000002056 ffffea00047a36c8 ffffea0004266648 ffff88810b8e1c50
raw: 000000000000003a ffff88811fd0b3f0 00000002ffffffff ffff88810031e000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x148c48(GFP_NOFS|__GFP_NOFAIL|__GFP_COMP|__GFP_HARDWALL|__GFP_MOVABLE), pid 308, tgid 307 (syz-executor348), ts 22218821051, free_ts 15091448006
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0x213/0x220 mm/page_alloc.c:2582
prep_new_page+0x1b/0x110 mm/page_alloc.c:2589
get_page_from_freelist+0x2762/0x27f0 mm/page_alloc.c:4387
__alloc_pages+0x3a1/0x780 mm/page_alloc.c:5664
__folio_alloc+0x15/0x40 mm/page_alloc.c:5696
__folio_alloc_node include/linux/gfp.h:245 [inline]
folio_alloc include/linux/gfp.h:274 [inline]
filemap_alloc_folio include/linux/pagemap.h:474 [inline]
__filemap_get_folio+0x6c0/0x970 mm/filemap.c:1976
pagecache_get_page+0x2f/0x110 mm/folio-compat.c:110
find_or_create_page include/linux/pagemap.h:615 [inline]
grow_dev_page fs/buffer.c:989 [inline]
grow_buffers fs/buffer.c:1054 [inline]
__getblk_slow fs/buffer.c:1081 [inline]
__getblk_gfp+0x205/0x7d0 fs/buffer.c:1376
sb_getblk_gfp include/linux/buffer_head.h:363 [inline]
ext4_ext_grow_indepth fs/ext4/extents.c:1334 [inline]
ext4_ext_create_new_leaf fs/ext4/extents.c:1435 [inline]
ext4_ext_insert_extent+0xfd2/0x4e00 fs/ext4/extents.c:2102
ext4_ext_map_blocks+0x1c31/0x71e0 fs/ext4/extents.c:4308
ext4_map_blocks+0xa42/0x1ce0 fs/ext4/inode.c:651
_ext4_get_block+0x23b/0x660 fs/ext4/inode.c:808
ext4_get_block+0x39/0x50 fs/ext4/inode.c:825
ext4_block_write_begin+0x55e/0x1200 fs/ext4/inode.c:1098
ext4_write_begin+0x5e0/0xfb0
ext4_da_write_begin+0x2ff/0x920 fs/ext4/inode.c:2987
page last free stack trace:
reset_page_owner include/linux/page_owner.h:26 [inline]
free_pages_prepare mm/page_alloc.c:1494 [inline]
free_pcp_prepare mm/page_alloc.c:1568 [inline]
free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3486
free_unref_page_list+0xf6/0x6c0 mm/page_alloc.c:3628
release_pages+0xf7f/0xfe0 mm/swap.c:1055
free_pages_and_swap_cache+0x8a/0xa0 mm/swap_state.c:314
tlb_batch_pages_flush mm/mmu_gather.c:59 [inline]
tlb_flush_mmu_free mm/mmu_gather.c:254 [inline]
tlb_flush_mmu mm/mmu_gather.c:261 [inline]
tlb_finish_mmu+0x1e0/0x3f0 mm/mmu_gather.c:361
unmap_region+0x2c1/0x310 mm/mmap.c:2383
do_mas_align_munmap+0xd05/0x1400 mm/mmap.c:2645
do_mas_munmap+0x23e/0x2b0 mm/mmap.c:2703
__vm_munmap+0x263/0x3a0 mm/mmap.c:2993
__do_sys_munmap mm/mmap.c:3019 [inline]
__se_sys_munmap mm/mmap.c:3015 [inline]
__x64_sys_munmap+0x6b/0x80 mm/mmap.c:3015
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+0x63/0xcd

Memory state around the buggy address:
ffff88812095df00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88812095df80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88812095e000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^
ffff88812095e080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88812095e100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
EXT4-fs error (device loop0): __ext4_get_inode_loc:4492: comm syz-executor348: Invalid inode table block 0 in block_group 0
EXT4-fs error (device loop0) in ext4_reserve_inode_write:5841: Corrupt filesystem
EXT4-fs error (device loop0): ext4_punch_hole:4137: inode #16: comm syz-executor348: mark_inode_dirty error
Reply all
Reply to author
Forward
0 new messages