syzbot


KASAN: slab-out-of-bounds Read in get_max_inline_xattr_value_size

Status: fixed on 2023/07/01 16:05
Subsystems: ext4
[Documentation on labels]
Reported-by: syzbot+1966db24521e5f6e23f7@syzkaller.appspotmail.com
Fix commit: 2220eaf90992 ext4: add bounds checking in get_max_inline_xattr_value_size()
First crash: 391d, last: 349d
Discussions (4)
Title Replies (including bot) Last reply
[PATCH -v2 1/2] ext4: add bounds checking in get_max_inline_xattr_value_size() 1 (1) 2023/05/13 05:12
[PATCH 1/2] ext4: add bounds checking in get_max_inline_xattr_value_size() 1 (1) 2023/05/12 22:03
[syzbot] [ext4?] KASAN: slab-out-of-bounds Read in get_max_inline_xattr_value_size 2 (3) 2023/05/12 21:28
[syzbot] [ext4?] KASAN: slab-out-of-bounds Read in ext4_group_desc_csum 17 (20) 2023/04/30 02:55
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: slab-out-of-bounds Read in get_max_inline_xattr_value_size ext4 C error 1 449d 449d 0/1 upstream: reported C repro on 2023/01/27 02:26
android-5-10 KASAN: slab-out-of-bounds Read in get_max_inline_xattr_value_size ext4 C error 4 391d 470d 2/2 fixed on 2023/06/07 17:22
android-54 KASAN: use-after-free Read in get_max_inline_xattr_value_size ext4 C 20 391d 470d 2/2 fixed on 2023/06/07 17:22
android-54 KASAN: use-after-free Read in get_max_inline_xattr_value_size (2) C 3 272d 280d 0/2 auto-obsoleted due to no activity on 2023/10/31 04:10
android-6-1 KASAN: use-after-free Read in get_max_inline_xattr_value_size origin:lts C error done 10 192d 280d 0/2 auto-obsoleted due to no activity on 2024/01/19 14:48
android-5-15 KASAN: use-after-free Read in get_max_inline_xattr_value_size ext4 C error 4 391d 470d 2/2 fixed on 2023/06/07 17:22
Last patch testing requests (4)
Created Duration User Patch Repo Result
2023/05/12 17:39 32m tytso@mit.edu patch https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev OK log
2023/05/12 16:14 12m tytso@mit.edu patch https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev error OK
2023/05/12 07:18 24m tytso@mit.edu patch https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev report log
2023/05/12 00:12 24m tytso@mit.edu patch https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev report log
Cause bisection attempts (1)
Created Duration User Patch Repo Result
2023/03/26 10:07 8h37m bisect upstream error job log (0)
marked invalid by spm@google.com

Sample crash report:
EXT4-fs (loop0): mounted filesystem 00000000-0000-0000-0000-000000000000 without journal. Quota mode: none.
EXT4-fs error (device loop0): ext4_xattr_ibody_get:669: inode #18: comm syz-executor366: corrupted in-inode xattr: bad magic number in in-inode xattr
==================================================================
BUG: KASAN: slab-use-after-free in get_max_inline_xattr_value_size+0x369/0x510 fs/ext4/inline.c:62
Read of size 4 at addr ffff88807c4ac084 by task syz-executor366/5076

CPU: 0 PID: 5076 Comm: syz-executor366 Not tainted 6.3.0-rc3-syzkaller-00338-gda8e7da11e4b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:319 [inline]
 print_report+0x163/0x540 mm/kasan/report.c:430
 kasan_report+0x176/0x1b0 mm/kasan/report.c:536
 get_max_inline_xattr_value_size+0x369/0x510 fs/ext4/inline.c:62
 ext4_get_max_inline_size+0x141/0x200 fs/ext4/inline.c:113
 ext4_prepare_inline_data+0x87/0x1d0 fs/ext4/inline.c:393
 ext4_da_write_inline_data_begin+0x208/0xe40 fs/ext4/inline.c:931
 ext4_da_write_begin+0x4da/0x960 fs/ext4/inode.c:3064
 generic_perform_write+0x300/0x5e0 mm/filemap.c:3926
 ext4_buffered_write_iter+0x122/0x3a0 fs/ext4/file.c:289
 ext4_file_write_iter+0x1d6/0x1930
 call_write_iter include/linux/fs.h:1851 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x7b2/0xbb0 fs/read_write.c:584
 ksys_write+0x1a0/0x2c0 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f63c54aea99
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:00007fff3f17f0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f63c54aea99
RDX: 0000000000000010 RSI: 0000000020000100 RDI: 0000000000000004
RBP: 0000000000000000 R08: 00007fff3f17f0f0 R09: 00007fff3f17f0f0
R10: 00007fff3f17f0f0 R11: 0000000000000246 R12: 00007f63c546d960
R13: 00007fff3f17f120 R14: 00007fff3f17f100 R15: 0000000000000000
 </TASK>

Allocated by task 4998:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4f/0x70 mm/kasan/common.c:52
 __kasan_slab_alloc+0x66/0x70 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:186 [inline]
 slab_post_alloc_hook+0x68/0x3a0 mm/slab.h:769
 slab_alloc_node mm/slub.c:3452 [inline]
 slab_alloc mm/slub.c:3460 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3467 [inline]
 kmem_cache_alloc+0x11f/0x2e0 mm/slub.c:3476
 anon_vma_chain_alloc mm/rmap.c:141 [inline]
 anon_vma_fork+0x1fa/0x580 mm/rmap.c:364
 dup_mmap kernel/fork.c:660 [inline]
 dup_mm kernel/fork.c:1545 [inline]
 copy_mm+0xae3/0x1670 kernel/fork.c:1594
 copy_process+0x1905/0x3fc0 kernel/fork.c:2264
 kernel_clone+0x222/0x800 kernel/fork.c:2679
 __do_sys_clone kernel/fork.c:2820 [inline]
 __se_sys_clone kernel/fork.c:2804 [inline]
 __x64_sys_clone+0x235/0x280 kernel/fork.c:2804
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 5013:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4f/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:521
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:162 [inline]
 slab_free_hook mm/slub.c:1781 [inline]
 slab_free_freelist_hook mm/slub.c:1807 [inline]
 slab_free mm/slub.c:3787 [inline]
 kmem_cache_free+0x297/0x520 mm/slub.c:3809
 anon_vma_chain_free mm/rmap.c:146 [inline]
 unlink_anon_vmas+0x59e/0x5f0 mm/rmap.c:447
 free_pgtables+0x348/0x4f0 mm/memory.c:383
 exit_mmap+0x2c1/0x850 mm/mmap.c:3040
 __mmput+0x115/0x3c0 kernel/fork.c:1204
 exit_mm+0x227/0x310 kernel/exit.c:563
 do_exit+0x612/0x2290 kernel/exit.c:856
 do_group_exit+0x206/0x2c0 kernel/exit.c:1019
 __do_sys_exit_group kernel/exit.c:1030 [inline]
 __se_sys_exit_group kernel/exit.c:1028 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1028
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88807c4ac070
 which belongs to the cache anon_vma_chain of size 80
The buggy address is located 20 bytes inside of
 freed 80-byte region [ffff88807c4ac070, ffff88807c4ac0c0)

The buggy address belongs to the physical page:
page:ffffea0001f12b00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7c4ac
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffff888140007280 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000240024 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 0x12800(GFP_NOWAIT|__GFP_NOWARN|__GFP_NORETRY), pid 4998, tgid 4998 (dhcpcd-run-hook), ts 47082738820, free_ts 47079213294
 prep_new_page mm/page_alloc.c:2553 [inline]
 get_page_from_freelist+0x3246/0x33c0 mm/page_alloc.c:4326
 __alloc_pages+0x255/0x670 mm/page_alloc.c:5592
 alloc_slab_page+0x6a/0x160 mm/slub.c:1851
 allocate_slab mm/slub.c:1998 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2051
 ___slab_alloc+0xa85/0x10a0 mm/slub.c:3193
 __slab_alloc mm/slub.c:3292 [inline]
 __slab_alloc_node mm/slub.c:3345 [inline]
 slab_alloc_node mm/slub.c:3442 [inline]
 slab_alloc mm/slub.c:3460 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3467 [inline]
 kmem_cache_alloc+0x1b9/0x2e0 mm/slub.c:3476
 anon_vma_chain_alloc mm/rmap.c:141 [inline]
 anon_vma_clone+0x98/0x4d0 mm/rmap.c:288
 anon_vma_fork+0x87/0x580 mm/rmap.c:351
 dup_mmap kernel/fork.c:660 [inline]
 dup_mm kernel/fork.c:1545 [inline]
 copy_mm+0xae3/0x1670 kernel/fork.c:1594
 copy_process+0x1905/0x3fc0 kernel/fork.c:2264
 kernel_clone+0x222/0x800 kernel/fork.c:2679
 __do_sys_clone kernel/fork.c:2820 [inline]
 __se_sys_clone kernel/fork.c:2804 [inline]
 __x64_sys_clone+0x235/0x280 kernel/fork.c:2804
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1454 [inline]
 free_pcp_prepare mm/page_alloc.c:1504 [inline]
 free_unref_page_prepare+0xe2f/0xe70 mm/page_alloc.c:3388
 free_unref_page_list+0x596/0x830 mm/page_alloc.c:3529
 release_pages+0x219e/0x2470 mm/swap.c:1042
 tlb_batch_pages_flush mm/mmu_gather.c:97 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:292 [inline]
 tlb_flush_mmu+0x100/0x210 mm/mmu_gather.c:299
 tlb_finish_mmu+0xd4/0x1f0 mm/mmu_gather.c:391
 exit_mmap+0x2c9/0x850 mm/mmap.c:3042
 __mmput+0x115/0x3c0 kernel/fork.c:1204
 exit_mm+0x227/0x310 kernel/exit.c:563
 do_exit+0x612/0x2290 kernel/exit.c:856
 do_group_exit+0x206/0x2c0 kernel/exit.c:1019
 __do_sys_exit_group kernel/exit.c:1030 [inline]
 __se_sys_exit_group kernel/exit.c:1028 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1028
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff88807c4abf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88807c4ac000: fa fb fb fb fb fb fb fb fb fb fc fc fc fc fa fb
>ffff88807c4ac080: fb fb fb fb fb fb fb fb fc fc fc fc fa fb fb fb
                   ^
 ffff88807c4ac100: fb fb fb fb fb fb fc fc fc fc fa fb fb fb fb fb
 ffff88807c4ac180: fb fb fb fb fc fc fc fc fa fb fb fb fb fb fb fb
==================================================================

Crashes (21):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/03/26 08:38 upstream da8e7da11e4b fbf0499a .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: slab-use-after-free Read in get_max_inline_xattr_value_size
2023/03/26 07:43 upstream da8e7da11e4b fbf0499a .config console log report syz [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: slab-out-of-bounds Read in get_max_inline_xattr_value_size
2023/05/07 07:43 upstream fc4354c6e5c2 90c93c40 .config console log report syz [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci2-upstream-fs KASAN: slab-use-after-free Read in get_max_inline_xattr_value_size
2023/04/23 18:43 upstream 622322f53c6d 2b32bd34 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-out-of-bounds Read in get_max_inline_xattr_value_size
2023/04/09 21:59 upstream cdc9718d5e59 71147e29 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-out-of-bounds Read in get_max_inline_xattr_value_size
2023/03/27 17:57 upstream 197b6b60ae7b f8f96aa9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-out-of-bounds Read in get_max_inline_xattr_value_size
2023/04/24 15:03 upstream 457391b03803 fdc18293 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in get_max_inline_xattr_value_size
2023/04/20 03:53 upstream 789b4a41c247 a219f34e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in get_max_inline_xattr_value_size
2023/04/19 14:17 upstream af67688dca57 94b4184e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in get_max_inline_xattr_value_size
2023/04/19 03:33 upstream af67688dca57 d931e9f0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in get_max_inline_xattr_value_size
2023/04/19 00:21 upstream af67688dca57 d931e9f0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in get_max_inline_xattr_value_size
2023/04/18 06:55 upstream 6a8f57ae2eb0 436577a9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in get_max_inline_xattr_value_size
2023/04/16 15:48 upstream 3e7bb4f24617 ec410564 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in get_max_inline_xattr_value_size
2023/04/16 04:31 upstream a7a55e27ad72 ec410564 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in get_max_inline_xattr_value_size
2023/04/15 14:15 upstream 7a934f4bd7d6 ec410564 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in get_max_inline_xattr_value_size
2023/04/12 14:09 upstream e62252bc55b6 1a1596b6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in get_max_inline_xattr_value_size
2023/04/11 08:37 upstream 0d3eb744aed4 71147e29 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in get_max_inline_xattr_value_size
2023/04/08 03:57 upstream aa318c48808c 71147e29 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in get_max_inline_xattr_value_size
2023/04/03 00:07 upstream 6ab608fe852b f325deb0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in get_max_inline_xattr_value_size
2023/04/02 12:44 upstream 00c7b5f4ddc5 f325deb0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in get_max_inline_xattr_value_size
2023/03/26 08:13 upstream da8e7da11e4b fbf0499a .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in get_max_inline_xattr_value_size
* Struck through repros no longer work on HEAD.