[ext4?] KASAN: slab-out-of-bounds Read in get_max_inline_xattr_value_size

0 views
Skip to first unread message

syzbot

unread,
Jan 6, 2023, 3:58:36 AM1/6/23
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 output: https://syzkaller.appspot.com/x/log.txt?x=144bf770480000
kernel config: https://syzkaller.appspot.com/x/.config?x=ce128396c79a61d9
dashboard link: https://syzkaller.appspot.com/bug?extid=fbd9585f2b17c63340f0
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=1161ce3a480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=120d8dac480000

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

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

==================================================================
BUG: KASAN: slab-out-of-bounds in get_max_inline_xattr_value_size+0x387/0x530 fs/ext4/inline.c:61
Read of size 4 at addr ffff8881065b8084 by task syz-executor304/366

CPU: 0 PID: 366 Comm: syz-executor304 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
get_max_inline_xattr_value_size+0x387/0x530 fs/ext4/inline.c:61
ext4_get_max_inline_size+0x142/0x200 fs/ext4/inline.c:112
ext4_try_to_write_inline_data+0xb1/0x570 fs/ext4/inline.c:673
ext4_write_begin+0x243/0x16f0 fs/ext4/inode.c:1170
ext4_da_write_begin+0x4a8/0xf10 fs/ext4/inode.c:3022
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:0x7f7b0ba28f09
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 d1 17 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:00007ffd02766bb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007ffd02766c08 RCX: 00007f7b0ba28f09
RDX: 0000000000000018 RSI: 0000000020000700 RDI: 0000000000000004
RBP: 0000000000000000 R08: 00007ffd02766ce0 R09: 00007ffd02766ce0
R10: 00007ffd02766ce0 R11: 0000000000000246 R12: 00007ffd02766c00
R13: 00007ffd02766ce0 R14: 431bde82d7b634db R15: 00007ffd02766be0

Allocated by task 1:
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_kmalloc+0xdc/0x110 mm/kasan/common.c:507
__kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516
kasan_kmalloc include/linux/kasan.h:269 [inline]
__kmalloc+0x1f7/0x360 mm/slub.c:4042
kmalloc include/linux/slab.h:557 [inline]
kzalloc include/linux/slab.h:664 [inline]
acpi_os_allocate_zeroed include/acpi/platform/aclinuxex.h:57 [inline]
acpi_ns_internalize_name+0x178/0x295 drivers/acpi/acpica/nsutils.c:331
acpi_ns_get_node_unlocked+0x18b/0x35c drivers/acpi/acpica/nsutils.c:666
acpi_ns_get_node+0x54/0x70 drivers/acpi/acpica/nsutils.c:726
acpi_ns_evaluate+0x36a/0xa10 drivers/acpi/acpica/nseval.c:62
acpi_ut_evaluate_object+0x14d/0x479 drivers/acpi/acpica/uteval.c:60
acpi_ut_execute_power_methods+0x108/0x254 drivers/acpi/acpica/uteval.c:288
acpi_get_object_info+0x63e/0x11eb drivers/acpi/acpica/nsxfname.c:366
acpi_set_pnp_ids drivers/acpi/scan.c:1287 [inline]
acpi_init_device_object+0x71f/0x3070 drivers/acpi/scan.c:1636
acpi_add_single_object+0x123/0x18d0 drivers/acpi/scan.c:1671
acpi_bus_check_add+0x42b/0xef0 drivers/acpi/scan.c:1924
acpi_ns_walk_namespace+0x242/0x4ad drivers/acpi/acpica/nswalk.c:231
acpi_walk_namespace+0xf2/0x121 drivers/acpi/acpica/nsxfeval.c:606
acpi_bus_scan+0xd1/0x150 drivers/acpi/scan.c:2105
acpi_scan_init+0x261/0x7fe drivers/acpi/scan.c:2274
acpi_init+0x173/0x226 drivers/acpi/bus.c:1255
do_one_initcall+0x1b5/0x610 init/main.c:1206
do_initcall_level+0x192/0x2f0 init/main.c:1279
do_initcalls+0x50/0x94 init/main.c:1295
do_basic_setup+0x88/0x91 init/main.c:1315
kernel_init_freeable+0x2ba/0x3f1 init/main.c:1519
kernel_init+0x11/0x290 init/main.c:1406
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299

The buggy address belongs to the object at ffff8881065b8078
which belongs to the cache kmalloc-8 of size 8
The buggy address is located 4 bytes to the right of
8-byte region [ffff8881065b8078, ffff8881065b8080)
The buggy address belongs to the page:
page:ffffea0004196e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8881065b8a28 pfn:0x1065b8
flags: 0x8000000000000200(slab)
raw: 8000000000000200 ffffea000418fc80 0000000f0000000f ffff888100043c80
raw: ffff8881065b8a28 0000000080660000 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, ts 1071430510, free_ts 999599686
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]
__kmalloc+0x24f/0x360 mm/slub.c:4038
kmalloc include/linux/slab.h:557 [inline]
kzalloc include/linux/slab.h:664 [inline]
acpi_os_allocate_zeroed include/acpi/platform/aclinuxex.h:57 [inline]
acpi_ns_internalize_name+0x178/0x295 drivers/acpi/acpica/nsutils.c:331
acpi_ns_get_node_unlocked+0x18b/0x35c drivers/acpi/acpica/nsutils.c:666
acpi_ns_get_node+0x54/0x70 drivers/acpi/acpica/nsutils.c:726
acpi_get_handle+0x1c3/0x284 drivers/acpi/acpica/nsxfname.c:98
acpi_has_method+0x9a/0xe0 drivers/acpi/utils.c:545
acpi_bus_get_power_flags drivers/acpi/scan.c:979 [inline]
acpi_add_single_object+0x1fd/0x18d0 drivers/acpi/scan.c:1681
acpi_bus_check_add+0x42b/0xef0 drivers/acpi/scan.c:1924
acpi_ns_walk_namespace+0x242/0x4ad drivers/acpi/acpica/nswalk.c:231
acpi_walk_namespace+0xf2/0x121 drivers/acpi/acpica/nsxfeval.c:606
acpi_bus_scan+0xd1/0x150 drivers/acpi/scan.c:2105
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 mm/page_alloc.c:3347 [inline]
free_the_page mm/page_alloc.c:5219 [inline]
__free_pages+0x390/0x570 mm/page_alloc.c:5228
__vunmap+0x846/0x980 mm/vmalloc.c:2276
free_work+0x66/0x90 mm/vmalloc.c:68
process_one_work+0x726/0xc10 kernel/workqueue.c:2296
worker_thread+0xb27/0x1550 kernel/workqueue.c:2442
kthread+0x349/0x3d0 kernel/kthread.c:313
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299

Memory state around the buggy address:
ffff8881065b7f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8881065b8000: fb fc fc fc fc fb fc fc fc fc fb fc fc fc fc fb
>ffff8881065b8080: fc fc fc fc fb fc fc fc fc fb fc fc fc fc fb fc
^
ffff8881065b8100: fc fc fc fb fc fc fc fc fb fc fc fc fc fb fc fc
ffff8881065b8180: fc fc fb fc fc fc fc fb fc fc fc fc fb fc fc fc
==================================================================
EXT4-fs error (device loop0): ext4_read_block_bitmap_nowait:437: comm syz-executor304: Invalid block bitmap block 0 in block_group 0


---
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,
Apr 20, 2023, 1:14:32 PM4/20/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=fbd9585f2b17c63340f0

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

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

syzbot

unread,
May 4, 2023, 1:14:58 PM5/4/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=fbd9585f2b17c63340f0

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

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

syzbot

unread,
May 18, 2023, 1:15:51 PM5/18/23
to jone...@google.com, syzkaller-a...@googlegroups.com, tudor....@linaro.org

syzbot

unread,
Jun 1, 2023, 1:16:56 PM6/1/23
to jone...@google.com, syzkaller-a...@googlegroups.com, tudor....@linaro.org

Tudor Ambarus

unread,
Jun 5, 2023, 5:55:55 AM6/5/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