syzbot


KASAN: use-after-free Read in search_by_entry_key (2)

Status: upstream: reported C repro on 2022/06/12 10:38
Reported-by: syzbot+ffe24b1afbc4cb5ae8fb@syzkaller.appspotmail.com
First crash: 111d, last: 10d

Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: KASAN: use-after-free Read in search_by_entry_key (log)
Repro: C syz .config

Fix bisection: the fix commit could be any of (bisect log):
  1c27f1fc1549 iov_iter: fix build issue due to possible type mis-match
  3cc40a443a04 Merge tag 'nios2_fixes_v6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux
similar bugs (6):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in search_by_entry_key (2) C 2 21d 533d 0/1 upstream: reported C repro on 2021/04/16 06:17
linux-4.14 KASAN: use-after-free Read in search_by_entry_key C done 3 633d 739d 1/1 fixed on 2021/02/21 17:18
linux-4.19 KASAN: use-after-free Read in search_by_entry_key (3) C error 1 106d 106d 0/1 upstream: reported C repro on 2022/06/17 02:59
linux-4.19 KASAN: use-after-free Read in search_by_entry_key C done 1 634d 724d 1/1 fixed on 2021/02/20 09:47
upstream KASAN: use-after-free Read in search_by_entry_key C done 3 719d 723d 21/24 fixed on 2021/03/10 01:49
linux-4.19 KASAN: use-after-free Read in search_by_entry_key (2) C done 2 415d 566d 1/1 fixed on 2021/09/10 21:17
Patch testing requests:
Created Duration User Patch Repo Result
2022/08/17 07:37 15m yin31149@gmail.com patch https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1c27f1fc1549f0e470429f5497a76ad28a37f21a report log

Sample crash report:
REISERFS (device loop0): checking transaction log (loop0)
REISERFS (device loop0): Using r5 hash to sort names
REISERFS (device loop0): using 3.5.x disk format
==================================================================
BUG: KASAN: use-after-free in bin_search_in_dir_item fs/reiserfs/namei.c:40 [inline]
BUG: KASAN: use-after-free in search_by_entry_key+0x581/0x1350 fs/reiserfs/namei.c:165
Read of size 4 at addr ffff888071669014 by task syz-executor155/3617

CPU: 0 PID: 3617 Comm: syz-executor155 Not tainted 6.0.0-rc6-syzkaller-00009-g60891ec99e14 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description+0x65/0x4b0 mm/kasan/report.c:317
 print_report+0x108/0x220 mm/kasan/report.c:433
 kasan_report+0xfb/0x130 mm/kasan/report.c:495
 bin_search_in_dir_item fs/reiserfs/namei.c:40 [inline]
 search_by_entry_key+0x581/0x1350 fs/reiserfs/namei.c:165
 reiserfs_find_entry+0x2c6/0x1a10 fs/reiserfs/namei.c:322
 reiserfs_lookup+0x1e3/0x4a0 fs/reiserfs/namei.c:368
 __lookup_slow+0x286/0x3e0 fs/namei.c:1685
 lookup_one_len+0x430/0x690 fs/namei.c:2711
 reiserfs_lookup_privroot+0x85/0x1e0 fs/reiserfs/xattr.c:973
 reiserfs_fill_super+0x21c0/0x2620 fs/reiserfs/super.c:2176
 mount_bdev+0x26c/0x3a0 fs/super.c:1400
 legacy_get_tree+0xea/0x180 fs/fs_context.c:610
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 do_new_mount+0x289/0xad0 fs/namespace.c:3040
 do_mount fs/namespace.c:3383 [inline]
 __do_sys_mount fs/namespace.c:3591 [inline]
 __se_sys_mount+0x2e3/0x3d0 fs/namespace.c:3568
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f65b64ebc8a
Code: 48 c7 c2 c0 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff eb d2 e8 a8 00 00 00 0f 1f 84 00 00 00 00 00 49 89 ca b8 a5 00 00 00 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:00007ffc7ac91528 EFLAGS: 00000286 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffc7ac91580 RCX: 00007f65b64ebc8a
RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007ffc7ac91540
RBP: 00007ffc7ac91540 R08: 00007ffc7ac91580 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000286 R12: 00000000200000a0
R13: 0000000000000003 R14: 0000000000000004 R15: 0000000000000004
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0001c59a40 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x71669
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea0001c59688 ffffea0001c7ae08 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 0x140dca(GFP_HIGHUSER_MOVABLE|__GFP_COMP|__GFP_ZERO), pid 3607, tgid 3607 (udevd), ts 50776327264, free_ts 50777750690
 prep_new_page mm/page_alloc.c:2532 [inline]
 get_page_from_freelist+0x72b/0x7a0 mm/page_alloc.c:4283
 __alloc_pages+0x259/0x560 mm/page_alloc.c:5515
 __folio_alloc+0xf/0x30 mm/page_alloc.c:5546
 vma_alloc_folio+0x662/0xb60 mm/mempolicy.c:2231
 alloc_page_vma include/linux/gfp.h:290 [inline]
 do_anonymous_page+0x329/0x1150 mm/memory.c:4084
 handle_pte_fault mm/memory.c:4909 [inline]
 __handle_mm_fault mm/memory.c:5053 [inline]
 handle_mm_fault+0x186b/0x35c0 mm/memory.c:5151
 do_user_addr_fault+0x69b/0xcb0 arch/x86/mm/fault.c:1397
 handle_page_fault arch/x86/mm/fault.c:1488 [inline]
 exc_page_fault+0x7a/0x120 arch/x86/mm/fault.c:1544
 asm_exc_page_fault+0x22/0x30
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1449 [inline]
 free_pcp_prepare+0x812/0x900 mm/page_alloc.c:1499
 free_unref_page_prepare mm/page_alloc.c:3380 [inline]
 free_unref_page_list+0xb4/0x7b0 mm/page_alloc.c:3522
 release_pages+0x22c3/0x2540 mm/swap.c:1012
 tlb_batch_pages_flush mm/mmu_gather.c:58 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:255 [inline]
 tlb_flush_mmu+0x850/0xa70 mm/mmu_gather.c:262
 tlb_finish_mmu+0xcb/0x200 mm/mmu_gather.c:353
 unmap_region+0x2ba/0x300 mm/mmap.c:2625
 __do_munmap+0x17ef/0x1cd0 mm/mmap.c:2836
 __do_sys_brk+0x452/0x6d0 mm/mmap.c:214
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff888071668f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888071668f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888071669000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                         ^
 ffff888071669080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888071669100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (4):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-smack-root 2022/09/21 02:45 upstream 60891ec99e14 c4b8ccfd .config log report syz C KASAN: use-after-free Read in search_by_entry_key
ci-upstream-kasan-gce-root 2022/06/12 07:40 upstream 1c27f1fc1549 0d5abf15 .config log report syz C KASAN: use-after-free Read in search_by_entry_key
ci-upstream-linux-next-kasan-gce-root 2022/09/04 18:35 linux-next e47eb90a0a9a 28811d0a .config log report syz C KASAN: use-after-free Read in search_by_entry_key
ci-upstream-kasan-gce-root 2022/06/12 07:02 upstream 1c27f1fc1549 0d5abf15 .config log report info KASAN: use-after-free Read in search_by_entry_key
* Struck through repros no longer work on HEAD.