syzbot


KASAN: use-after-free Read in ext4_search_dir

Status: fixed on 2024/02/21 18:23
Subsystems: ext4
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+34a0f26f0f61c4888ea4@syzkaller.appspotmail.com
Fix commit: 6f861765464f fs: Block writes to mounted block devices
First crash: 355d, last: 109d
Cause bisection: failed (error log, bisect log)
  
Fix bisection: fixed by (bisect log) :
commit 6f861765464f43a71462d52026fbddfc858239a5
Author: Jan Kara <jack@suse.cz>
Date: Wed Nov 1 17:43:10 2023 +0000

  fs: Block writes to mounted block devices

  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ext4?] KASAN: use-after-free Read in ext4_search_dir 2 (5) 2024/02/19 11:38
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_search_dir origin:upstream C 1 12d 314d 0/3 upstream: reported C repro on 2023/06/16 15:52
android-54 KASAN: use-after-free Read in ext4_search_dir C 2 7d17h 11d 0/2 upstream: reported C repro on 2024/04/15 06:47
android-6-1 KASAN: use-after-free Read in ext4_search_dir origin:upstream C error 3 11d 186d 0/2 upstream: reported C repro on 2023/10/22 16:55
android-5-10 KASAN: slab-out-of-bounds Read in ext4_search_dir C 2 11d 161d 0/2 upstream: reported C repro on 2023/11/17 09:38
linux-6.1 KASAN: use-after-free Read in ext4_search_dir origin:upstream C 1 8d16h 312d 0/3 upstream: reported C repro on 2023/06/18 19:29
android-5-15 KASAN: slab-out-of-bounds Read in ext4_search_dir origin:upstream C 1 15d 161d 0/2 upstream: reported C repro on 2023/11/17 09:38
Last patch testing requests (10)
Created Duration User Patch Repo Result
2024/02/16 21:50 28m retest repro upstream OK log
2024/02/14 18:39 21m retest repro upstream OK log
2024/02/14 18:39 20m retest repro upstream OK log
2024/01/05 00:22 14m retest repro upstream report log
2024/01/04 23:29 22m retest repro linux-next OK log
2023/12/06 17:45 15m retest repro upstream report log
2023/12/06 17:56 13m retest repro upstream report log
2023/12/06 17:45 10m retest repro upstream report log
2023/10/26 03:25 16m retest repro linux-next report log
2023/09/12 05:35 14m retest repro upstream report log
Fix bisection attempts (3)
Created Duration User Patch Repo Result
2024/02/17 02:30 4h23m bisect fix upstream job log (1)
2023/07/28 08:18 1h22m bisect fix upstream job log (0) log
2023/06/16 08:13 38m bisect fix upstream job log (0) log

Sample crash report:
EXT4-fs (loop0): mounting ext3 file system using the ext4 subsystem
EXT4-fs (loop0): 1 truncate cleaned up
EXT4-fs (loop0): mounted filesystem 00000000-0000-0000-0000-000000000000 r/w without journal. Quota mode: none.
==================================================================
BUG: KASAN: slab-out-of-bounds in ext4_search_dir+0xf2/0x1b0 fs/ext4/namei.c:1539
Read of size 1 at addr ffff88801f58d3ed by task syz-executor303/4999

CPU: 0 PID: 4999 Comm: syz-executor303 Not tainted 6.4.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/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:351 [inline]
 print_report+0x163/0x540 mm/kasan/report.c:462
 kasan_report+0x176/0x1b0 mm/kasan/report.c:572
 ext4_search_dir+0xf2/0x1b0 fs/ext4/namei.c:1539
 ext4_find_inline_entry+0x4ba/0x5e0 fs/ext4/inline.c:1719
 __ext4_find_entry+0x2b4/0x1b30 fs/ext4/namei.c:1612
 ext4_lookup_entry fs/ext4/namei.c:1767 [inline]
 ext4_lookup+0x17a/0x750 fs/ext4/namei.c:1835
 lookup_open fs/namei.c:3470 [inline]
 open_last_lookups fs/namei.c:3560 [inline]
 path_openat+0x11e9/0x3170 fs/namei.c:3788
 do_filp_open+0x234/0x490 fs/namei.c:3818
 do_sys_openat2+0x13f/0x500 fs/open.c:1356
 do_sys_open fs/open.c:1372 [inline]
 __do_sys_open fs/open.c:1380 [inline]
 __se_sys_open fs/open.c:1376 [inline]
 __x64_sys_open+0x225/0x270 fs/open.c:1376
 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:0x7fd8cce6ccf9
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:00007fff8e028488 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 0000000000010c1d RCX: 00007fd8cce6ccf9
RDX: 0000000000000000 RSI: 0000000000141042 RDI: 0000000020000100
RBP: 0000000000000000 R08: 000000000001f210 R09: 00000000200012c0
R10: 00007fd8bc65f000 R11: 0000000000000246 R12: 00007fff8e0284bc
R13: 00007fff8e0284f0 R14: 00007fff8e0284d0 R15: 0000000000000004
 </TASK>

Allocated by task 4730:
 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:711
 kmem_cache_alloc_bulk+0x3d2/0x4b0 mm/slub.c:4033
 mt_alloc_bulk lib/maple_tree.c:164 [inline]
 mas_alloc_nodes+0x3df/0x800 lib/maple_tree.c:1309
 mas_node_count_gfp lib/maple_tree.c:1367 [inline]
 mas_preallocate+0x131/0x350 lib/maple_tree.c:5781
 vma_iter_prealloc mm/internal.h:1029 [inline]
 __split_vma+0x1e0/0x7f0 mm/mmap.c:2253
 do_vmi_align_munmap+0x4ac/0x1820 mm/mmap.c:2398
 do_vmi_munmap+0x24a/0x2b0 mm/mmap.c:2530
 mmap_region+0x811/0x2250 mm/mmap.c:2578
 do_mmap+0x8c9/0xf70 mm/mmap.c:1394
 vm_mmap_pgoff+0x1db/0x410 mm/util.c:543
 ksys_mmap_pgoff+0x4f9/0x6d0 mm/mmap.c:1440
 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 4730:
 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:3786 [inline]
 kmem_cache_free_bulk+0x506/0x760 mm/slub.c:3904
 mt_free_bulk lib/maple_tree.c:169 [inline]
 mas_destroy+0x1c50/0x2310 lib/maple_tree.c:5836
 mas_store_prealloc+0x351/0x460 lib/maple_tree.c:5766
 vma_complete+0x1ec/0xb40 mm/mmap.c:585
 __split_vma+0x7c2/0x7f0 mm/mmap.c:2290
 do_vmi_align_munmap+0x4ac/0x1820 mm/mmap.c:2398
 do_vmi_munmap+0x24a/0x2b0 mm/mmap.c:2530
 mmap_region+0x811/0x2250 mm/mmap.c:2578
 do_mmap+0x8c9/0xf70 mm/mmap.c:1394
 vm_mmap_pgoff+0x1db/0x410 mm/util.c:543
 ksys_mmap_pgoff+0x4f9/0x6d0 mm/mmap.c:1440
 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 ffff88801f58d200
 which belongs to the cache maple_node of size 256
The buggy address is located 237 bytes to the right of
 allocated 256-byte region [ffff88801f58d200, ffff88801f58d300)

The buggy address belongs to the physical page:
page:ffffea00007d6300 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1f58c
head:ffffea00007d6300 order:1 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000010200 ffff888012e4d000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4730, tgid 4730 (S50sshd), ts 42005657182, free_ts 36967331489
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1731
 prep_new_page mm/page_alloc.c:1738 [inline]
 get_page_from_freelist+0x321c/0x33a0 mm/page_alloc.c:3502
 __alloc_pages+0x255/0x670 mm/page_alloc.c:4768
 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:3192
 __kmem_cache_alloc_bulk mm/slub.c:3951 [inline]
 kmem_cache_alloc_bulk+0x196/0x4b0 mm/slub.c:4026
 mt_alloc_bulk lib/maple_tree.c:164 [inline]
 mas_alloc_nodes+0x3df/0x800 lib/maple_tree.c:1309
 mas_node_count_gfp lib/maple_tree.c:1367 [inline]
 mas_preallocate+0x131/0x350 lib/maple_tree.c:5781
 vma_iter_prealloc mm/internal.h:1029 [inline]
 mmap_region+0x1342/0x2250 mm/mmap.c:2711
 do_mmap+0x8c9/0xf70 mm/mmap.c:1394
 vm_mmap_pgoff+0x1db/0x410 mm/util.c:543
 ksys_mmap_pgoff+0x4f9/0x6d0 mm/mmap.c:1440
 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:1302 [inline]
 free_unref_page_prepare+0x903/0xa30 mm/page_alloc.c:2564
 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2659
 qlist_free_all+0x22/0x60 mm/kasan/quarantine.c:185
 kasan_quarantine_reduce+0x14b/0x160 mm/kasan/quarantine.c:292
 __kasan_slab_alloc+0x23/0x70 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:186 [inline]
 slab_post_alloc_hook+0x68/0x3a0 mm/slab.h:711
 slab_alloc_node mm/slub.c:3451 [inline]
 slab_alloc mm/slub.c:3459 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3466 [inline]
 kmem_cache_alloc_lru+0x11f/0x2e0 mm/slub.c:3482
 __d_alloc+0x31/0x710 fs/dcache.c:1769
 d_alloc fs/dcache.c:1849 [inline]
 d_alloc_parallel+0xce/0x13a0 fs/dcache.c:2638
 lookup_open fs/namei.c:3417 [inline]
 open_last_lookups fs/namei.c:3560 [inline]
 path_openat+0x90e/0x3170 fs/namei.c:3788
 do_filp_open+0x234/0x490 fs/namei.c:3818
 do_sys_openat2+0x13f/0x500 fs/open.c:1356
 do_sys_open fs/open.c:1372 [inline]
 __do_sys_openat fs/open.c:1388 [inline]
 __se_sys_openat fs/open.c:1383 [inline]
 __x64_sys_openat+0x247/0x290 fs/open.c:1383
 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:
 ffff88801f58d280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88801f58d300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88801f58d380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                                                          ^
 ffff88801f58d400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88801f58d480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (20):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/17 07:29 upstream f1fcbaa18b28 11c89444 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci-upstream-kasan-gce-smack-root KASAN: slab-out-of-bounds Read in ext4_search_dir
2023/11/17 08:55 upstream 7475e51b8796 cb976f63 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci2-upstream-fs KASAN: use-after-free Read in ext4_search_dir
2023/05/17 08:12 upstream f1fcbaa18b28 11c89444 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci2-upstream-fs KASAN: use-after-free Read in ext4_search_dir
2023/08/03 00:18 linux-next 626c67169f99 39a91c18 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in ext4_search_dir
2023/06/23 12:45 upstream 8a28a0b6f1a1 09ffe269 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci-upstream-kasan-gce-root KASAN: slab-out-of-bounds Read in ext4_search_dir
2023/12/21 23:18 upstream 9a6b294ab496 4f9530a3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in ext4_search_dir
2023/12/20 01:50 upstream 55cb5f43689d 3ad490ea .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in ext4_search_dir
2023/11/17 08:25 upstream 7475e51b8796 cb976f63 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in ext4_search_dir
2023/11/03 13:56 upstream 8f6f76a6a29f c4ac074c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in ext4_search_dir
2023/10/11 19:40 upstream 1c8b86a3799f 83165b57 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: use-after-free Read in ext4_search_dir
2023/09/28 09:24 upstream 633b47cb009d c2ab1e5d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in ext4_search_dir
2023/08/29 05:06 upstream 727dbda16b83 7ba13a15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in ext4_search_dir
2023/08/19 17:53 upstream aa9ea98cca3a d216d8a0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in ext4_search_dir
2023/05/17 07:02 upstream f1fcbaa18b28 11c89444 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in ext4_search_dir
2023/05/07 07:18 upstream fc4354c6e5c2 90c93c40 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in ext4_search_dir
2023/09/16 23:31 linux-next dfa449a58323 0b6a67ac .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in ext4_search_dir
2024/01/07 16:14 upstream 52b1853b080a d0304e9c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-out-of-bounds Read in ext4_search_dir
2023/11/22 17:40 upstream c2d5304e6c64 03e12510 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-out-of-bounds Read in ext4_search_dir
2023/10/12 02:06 upstream 8182d7a3f1b8 83165b57 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-out-of-bounds Read in ext4_search_dir
2023/09/20 03:40 upstream 2cf0f7156238 0b6a67ac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-out-of-bounds Read in ext4_search_dir
* Struck through repros no longer work on HEAD.