syzbot


KASAN: use-after-free Read in ext4_xattr_inode_dec_ref_all

Status: upstream: reported C repro on 2025/03/27 11:49
Reported-by: syzbot+786264827f156d1819c6@syzkaller.appspotmail.com
First crash: 114d, last: 86d
Fix bisection: fixed by (bisect log) :
commit 76c365fa7e2a8bb85f0190cdb4b8cdc99b2fdce3
Author: Bhupesh <bhupesh@igalia.com>
Date: Tue Jan 28 08:27:50 2025 +0000

  ext4: ignore xattrs past end

  
Last patch testing requests (5)
Created Duration User Patch Repo Result
2025/07/04 04:33 11m retest repro android13-5.10-lts report log
2025/07/04 04:33 19m retest repro android13-5.10-lts OK log
2025/04/24 12:20 8m retest repro android13-5.10-lts report log
2025/04/24 12:20 7m retest repro android13-5.10-lts report log
2025/04/24 12:20 6m retest repro android13-5.10-lts report log

Sample crash report:
EXT4-fs error (device loop9): __ext4_get_inode_loc_noinmem:4557: inode #1953789044: comm syz.9.67: unable to read itable block
EXT4-fs error (device loop9): ext4_xattr_inode_iget:409: comm syz.9.67: error while reading EA inode 1953789044 err=-5
==================================================================
BUG: KASAN: use-after-free in ext4_xattr_inode_dec_ref_all+0xd04/0xfa0 fs/ext4/xattr.c:1134
Read of size 4 at addr ffff88812b3fc01c by task syz.9.67/600

CPU: 0 PID: 600 Comm: syz.9.67 Not tainted 5.10.234-syzkaller-00157-ge0b88ee5f09c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:435 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:452
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308
 ext4_xattr_inode_dec_ref_all+0xd04/0xfa0 fs/ext4/xattr.c:1134
 ext4_xattr_release_block+0x4cf/0xa40 fs/ext4/xattr.c:1254
 ext4_xattr_delete_inode+0xaf9/0xc80 fs/ext4/xattr.c:2943
 ext4_evict_inode+0x1095/0x1730 fs/ext4/inode.c:300
 evict+0x526/0x9c0 fs/inode.c:612
 iput_final fs/inode.c:1736 [inline]
 iput+0x632/0x7e0 fs/inode.c:1762
 do_unlinkat+0x48e/0x8b0 fs/namei.c:4042
 __do_sys_unlinkat fs/namei.c:4077 [inline]
 __se_sys_unlinkat fs/namei.c:4070 [inline]
 __x64_sys_unlinkat+0xcd/0xf0 fs/namei.c:4070
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:-1
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f2b0814b169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2b07bbd038 EFLAGS: 00000246 ORIG_RAX: 0000000000000107
RAX: ffffffffffffffda RBX: 00007f2b08363fa0 RCX: 00007f2b0814b169
RDX: 0000000000000000 RSI: 0000200000000c40 RDI: ffffffffffffff9c
RBP: 00007f2b081cc2a0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f2b08363fa0 R15: 00007ffead7a2a78

The buggy address belongs to the page:
page:ffffea0004acff00 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x12b3fc
flags: 0x4000000000000000()
raw: 4000000000000000 ffffea0004acdb48 ffffea00049b19c8 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 0x108c48(GFP_NOFS|__GFP_NOFAIL|__GFP_HARDWALL|__GFP_MOVABLE), pid 563, ts 46236628257, free_ts 46441347434
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2456 [inline]
 prep_new_page+0x166/0x180 mm/page_alloc.c:2462
 get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4254
 __alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5348
 __alloc_pages include/linux/gfp.h:544 [inline]
 __alloc_pages_node include/linux/gfp.h:557 [inline]
 alloc_pages_node include/linux/gfp.h:571 [inline]
 alloc_pages include/linux/gfp.h:590 [inline]
 __page_cache_alloc include/linux/pagemap.h:290 [inline]
 pagecache_get_page+0x669/0x950 mm/filemap.c:1848
 find_or_create_page include/linux/pagemap.h:402 [inline]
 grow_dev_page fs/buffer.c:976 [inline]
 grow_buffers fs/buffer.c:1045 [inline]
 __getblk_slow fs/buffer.c:1072 [inline]
 __getblk_gfp+0x221/0x7e0 fs/buffer.c:1370
 sb_getblk include/linux/buffer_head.h:361 [inline]
 ext4_xattr_block_set+0x2204/0x3400 fs/ext4/xattr.c:2099
 ext4_xattr_set_handle+0xd58/0x14e0 fs/ext4/xattr.c:2403
 ext4_initxattrs+0xa7/0x120 fs/ext4/xattr_security.c:43
 security_inode_init_security+0x252/0x390 security/security.c:1033
 ext4_init_security+0x34/0x40 fs/ext4/xattr_security.c:57
 __ext4_new_inode+0x30b0/0x3ea0 fs/ext4/ialloc.c:1327
 ext4_create+0x267/0x530 fs/ext4/namei.c:2823
 lookup_open fs/namei.c:3247 [inline]
 open_last_lookups fs/namei.c:3317 [inline]
 path_openat+0x1377/0x3000 fs/namei.c:3506
 do_filp_open+0x21c/0x460 fs/namei.c:3536
 do_sys_openat2+0x13f/0x710 fs/open.c:1217
 do_sys_open fs/open.c:1233 [inline]
 __do_sys_creat fs/open.c:1309 [inline]
 __se_sys_creat fs/open.c:1303 [inline]
 __x64_sys_creat+0x11f/0x160 fs/open.c:1303
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1349 [inline]
 free_pcp_prepare mm/page_alloc.c:1421 [inline]
 free_unref_page_prepare+0x2ae/0x2d0 mm/page_alloc.c:3336
 free_unref_page_list+0x122/0xb20 mm/page_alloc.c:3443
 release_pages+0xea0/0xef0 mm/swap.c:1103
 __pagevec_release+0x84/0x100 mm/swap.c:1123
 pagevec_release include/linux/pagevec.h:88 [inline]
 __invalidate_mapping_pages+0xa67/0xb50 mm/truncate.c:607
 invalidate_mapping_pages+0x27/0x30 mm/truncate.c:632
 invalidate_bdev+0xa3/0x140 fs/block_dev.c:97
 ext4_put_super+0x67d/0xc70 fs/ext4/super.c:1237
 generic_shutdown_super+0x147/0x320 fs/super.c:465
 kill_block_super+0x7e/0xe0 fs/super.c:1469
 deactivate_locked_super+0xad/0x110 fs/super.c:335
 deactivate_super+0xbe/0xf0 fs/super.c:366
 cleanup_mnt+0x45c/0x510 fs/namespace.c:1118
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1125
 task_work_run+0x129/0x190 kernel/task_work.c:189
 exit_task_work include/linux/task_work.h:33 [inline]
 do_exit+0xc83/0x2a50 kernel/exit.c:863

Memory state around the buggy address:
 ffff88812b3fbf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88812b3fbf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88812b3fc000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                            ^
 ffff88812b3fc080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88812b3fc100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================
EXT4-fs warning (device loop9): ext4_evict_inode:303: xattr delete (err -117)

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/04/09 21:55 android13-5.10-lts e0b88ee5f09c 47d015b1 .config console log report syz / log [disk image] [vmlinux] [kernel image] [mounted in repro (corrupt fs)] ci2-android-5-10 KASAN: use-after-free Read in ext4_xattr_inode_dec_ref_all
2025/04/02 12:21 android13-5.10-lts 094fc3778d6b c799dfdd .config console log report syz / log [disk image] [vmlinux] [kernel image] [mounted in repro #1 (corrupt fs)] [mounted in repro #2 (corrupt fs)] ci2-android-5-10 KASAN: use-after-free Read in ext4_xattr_inode_dec_ref_all
2025/03/27 11:48 android13-5.10-lts 094fc3778d6b 20510e88 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (clean fs)] ci2-android-5-10 KASAN: use-after-free Read in ext4_xattr_inode_dec_ref_all
* Struck through repros no longer work on HEAD.