syzbot


KASAN: use-after-free Read in ext4_convert_inline_data_nolock

Status: auto-obsoleted due to no activity on 2025/02/20 23:05
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+7ffb92f4df72e7e5205e@syzkaller.appspotmail.com
First crash: 299d, last: 102d
Fix bisection: fixed by (bisect log) :
commit f595035794f923157ce077df6031a88fa55ad9fb
Author: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Date: Wed Aug 21 15:23:22 2024 +0000

  ext4: return error on ext4_find_inline_entry

  
Bug presence (4)
Date Name Commit Repro Result
2024/11/12 android14-6.1 (ToT) 38859a233e31 C [report] KASAN: use-after-free Read in ext4_convert_inline_data_nolock
2024/05/01 lts (merge base) 883d1a956208 C [report] KASAN: use-after-free Read in ext4_convert_inline_data_nolock
2024/05/01 upstream (ToT) 18daea77cca6 C [report] KASAN: use-after-free Read in ext4_read_inline_data
2024/11/12 upstream (ToT) 14b6320953a3 C Didn't crash
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in ext4_convert_inline_data_nolock origin:upstream C error 1 51d 644d 0/3 upstream: reported C repro on 2023/05/21 13:36
upstream KASAN: slab-use-after-free Read in ext4_convert_inline_data_nolock ext4 C error done 7 422d 699d 25/28 fixed on 2024/02/03 12:44
android-5-10 KASAN: use-after-free Read in ext4_convert_inline_data_nolock syz error 1 166d 299d 0/2 auto-obsoleted due to no activity on 2024/12/28 07:38
android-5-15 KASAN: use-after-free Read in ext4_convert_inline_data_nolock missing-backport origin:upstream C error 1 114d 270d 0/2 auto-obsoleted due to no activity on 2025/02/08 19:49
linux-6.1 KASAN: use-after-free Read in ext4_convert_inline_data_nolock origin:upstream C 2 5d18h 680d 0/3 upstream: reported C repro on 2023/04/15 09:27
android-54 KASAN: use-after-free Read in ext4_convert_inline_data_nolock C 1 133d 299d 0/2 upstream: reported C repro on 2024/04/30 09:11
Last patch testing requests (1)
Created Duration User Patch Repo Result
2024/05/14 16:30 6m retest repro android14-6.1 report log
Fix bisection attempts (5)
Created Duration User Patch Repo Result
2024/12/29 08:24 6h12m bisect fix android14-6.1 OK (1) job log
2024/10/30 22:04 2h18m bisect fix android14-6.1 OK (0) job log log
2024/09/30 02:37 57m bisect fix android14-6.1 OK (0) job log log
2024/08/22 05:05 45m bisect fix android14-6.1 OK (0) job log log
2024/06/13 16:38 1h00m bisect fix android14-6.1 OK (0) job log log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in ext4_read_inline_data fs/ext4/inline.c:210 [inline]
BUG: KASAN: use-after-free in ext4_convert_inline_data_nolock+0x311/0xa70 fs/ext4/inline.c:1216
Read of size 52 at addr ffff888127838459 by task syz.4.943/4088

CPU: 1 PID: 4088 Comm: syz.4.943 Not tainted 6.1.84-syzkaller-00005-g96d66062d076 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
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
 memcpy+0x2d/0x70 mm/kasan/shadow.c:65
 ext4_read_inline_data fs/ext4/inline.c:210 [inline]
 ext4_convert_inline_data_nolock+0x311/0xa70 fs/ext4/inline.c:1216
 ext4_try_add_inline_entry+0x7ff/0xb60 fs/ext4/inline.c:1342
 ext4_add_entry+0x5e4/0xed0 fs/ext4/namei.c:2409
 ext4_add_nondir+0x97/0x290 fs/ext4/namei.c:2796
 ext4_create+0x372/0x550 fs/ext4/namei.c:2842
 lookup_open fs/namei.c:3483 [inline]
 open_last_lookups fs/namei.c:3551 [inline]
 path_openat+0x12ee/0x2d60 fs/namei.c:3781
 do_filp_open+0x230/0x480 fs/namei.c:3811
 do_sys_openat2+0x13f/0x850 fs/open.c:1341
 do_sys_open fs/open.c:1357 [inline]
 __do_sys_creat fs/open.c:1433 [inline]
 __se_sys_creat fs/open.c:1427 [inline]
 __x64_sys_creat+0x11f/0x160 fs/open.c:1427
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f89ca375bd9
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:00007f89cb079048 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007f89ca503f60 RCX: 00007f89ca375bd9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000440
RBP: 00007f89ca3e4e60 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f89ca503f60 R15: 00007ffd165c1988
 </TASK>

Allocated by task 837:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505
 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:333
 kasan_slab_alloc include/linux/kasan.h:202 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:768
 slab_alloc_node mm/slub.c:3421 [inline]
 slab_alloc mm/slub.c:3429 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3436 [inline]
 kmem_cache_alloc+0x175/0x2c0 mm/slub.c:3445
 kmem_cache_zalloc include/linux/slab.h:682 [inline]
 __kernfs_new_node+0xdb/0x700 fs/kernfs/dir.c:608
 kernfs_new_node+0x130/0x230 fs/kernfs/dir.c:684
 kernfs_create_link+0xba/0x210 fs/kernfs/symlink.c:39
 sysfs_do_create_link_sd+0x89/0x110 fs/sysfs/symlink.c:44
 sysfs_do_create_link fs/sysfs/symlink.c:80 [inline]
 sysfs_create_link+0x68/0x80 fs/sysfs/symlink.c:92
 device_add_class_symlinks drivers/base/core.c:3413 [inline]
 device_add+0x7bf/0xf10 drivers/base/core.c:3619
 netdev_register_kobject+0x177/0x320 net/core/net-sysfs.c:2011
 register_netdevice+0xe43/0x1490 net/core/dev.c:10106
 veth_newlink+0x7fc/0xc70 drivers/net/veth.c:1775
 rtnl_newlink_create net/core/rtnetlink.c:3390 [inline]
 __rtnl_newlink net/core/rtnetlink.c:3610 [inline]
 rtnl_newlink+0x14c6/0x2030 net/core/rtnetlink.c:3623
 rtnetlink_rcv_msg+0x9a5/0xca0 net/core/rtnetlink.c:6121
 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2518
 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:6139
 netlink_unicast_kernel net/netlink/af_netlink.c:1327 [inline]
 netlink_unicast+0x906/0xab0 net/netlink/af_netlink.c:1353
 netlink_sendmsg+0xa15/0xd30 net/netlink/af_netlink.c:1875
 sock_sendmsg_nosec net/socket.c:716 [inline]
 __sock_sendmsg net/socket.c:728 [inline]
 __sys_sendto+0x480/0x600 net/socket.c:2138
 __do_sys_sendto net/socket.c:2150 [inline]
 __se_sys_sendto net/socket.c:2146 [inline]
 __x64_sys_sendto+0xe5/0x100 net/socket.c:2146
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff8881278383e8
 which belongs to the cache kernfs_node_cache of size 136
The buggy address is located 113 bytes inside of
 136-byte region [ffff8881278383e8, ffff888127838470)

The buggy address belongs to the physical page:
page:ffffea00049e0e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888127838320 pfn:0x127838
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea00049e0d08 ffffea0004d93d08 ffff8881002a0f00
raw: ffff888127838320 000000000014000c 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 837, tgid 837 (syz-executor), ts 49527387965, free_ts 49212707716
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597
 get_page_from_freelist+0x27ea/0x2870 mm/page_alloc.c:4425
 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5714
 alloc_slab_page+0x6c/0xf0
 allocate_slab mm/slub.c:1962 [inline]
 new_slab+0x90/0x3e0 mm/slub.c:2015
 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3203
 __slab_alloc+0x5d/0xa0 mm/slub.c:3302
 slab_alloc_node mm/slub.c:3387 [inline]
 slab_alloc mm/slub.c:3429 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3436 [inline]
 kmem_cache_alloc+0x1b9/0x2c0 mm/slub.c:3445
 kmem_cache_zalloc include/linux/slab.h:682 [inline]
 __kernfs_new_node+0xdb/0x700 fs/kernfs/dir.c:608
 kernfs_new_node+0x130/0x230 fs/kernfs/dir.c:684
 __kernfs_create_file+0x4a/0x270 fs/kernfs/file.c:1043
 sysfs_add_file_mode_ns+0x1c8/0x270 fs/sysfs/file.c:294
 create_files fs/sysfs/group.c:64 [inline]
 internal_create_group+0x545/0xed0 fs/sysfs/group.c:148
 sysfs_create_group+0x1f/0x30 fs/sysfs/group.c:174
 netdev_queue_add_kobject net/core/net-sysfs.c:1668 [inline]
 netdev_queue_update_kobjects+0x21c/0x4a0 net/core/net-sysfs.c:1714
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1498 [inline]
 free_pcp_prepare mm/page_alloc.c:1572 [inline]
 free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3498
 free_unref_page+0xb2/0x5c0 mm/page_alloc.c:3594
 free_the_page mm/page_alloc.c:798 [inline]
 __free_pages+0x61/0xf0 mm/page_alloc.c:5803
 __vunmap+0x9f3/0xb60 mm/vmalloc.c:2728
 __vfree mm/vmalloc.c:2776 [inline]
 vfree+0x5c/0x80 mm/vmalloc.c:2807
 kcov_put kernel/kcov.c:428 [inline]
 kcov_close+0x2b/0x50 kernel/kcov.c:524
 __fput+0x3ab/0x870 fs/file_table.c:320
 ____fput+0x15/0x20 fs/file_table.c:348
 task_work_run+0x24d/0x2e0 kernel/task_work.c:179
 exit_task_work include/linux/task_work.h:38 [inline]
 do_exit+0xbd5/0x2b80 kernel/exit.c:875
 do_group_exit+0x21a/0x2d0 kernel/exit.c:1025
 __do_sys_exit_group kernel/exit.c:1036 [inline]
 __se_sys_exit_group kernel/exit.c:1034 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1034
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff888127838300: fc fc fc fc fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888127838380: fb fb fb fb fb fc fc fc fc fc fc fc fc fb fb fb
>ffff888127838400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
                                                    ^
 ffff888127838480: fc fc fc fc fc fc 00 00 00 00 00 00 00 00 00 00
 ffff888127838500: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fb
==================================================================
EXT4-fs error (device loop4): ext4_check_all_de:655: inode #12: block 7: comm syz.4.943: bad entry in directory: rec_len % 4 != 0 - offset=0, inode=95227824, rec_len=26915, size=108 fake=0

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/07/15 03:10 android14-6.1 96d66062d076 eaeb5c15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in ext4_convert_inline_data_nolock
2024/04/30 15:28 android14-6.1 6364d594125d 3ce4924c .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci2-android-6-1 KASAN: use-after-free Read in ext4_convert_inline_data_nolock
* Struck through repros no longer work on HEAD.