syzbot


KASAN: use-after-free Read in sysv_new_block

Status: upstream: reported C repro on 2022/12/01 12:49
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+eda782c229b243c648e9@syzkaller.appspotmail.com
First crash: 501d, last: 21d
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 (3)
Title Replies (including bot) Last reply
[syzbot] Monthly fs report (Mar 2024) 0 (1) 2024/03/16 12:09
[syzbot] KASAN: use-after-free Read in sysv_new_block 0 (2) 2024/02/08 01:37
[syzbot] Monthly fs report (Dec 2023) 0 (1) 2023/12/12 22:02
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in sysv_new_block sysv C error 4 472d 502d 0/1 upstream: reported C repro on 2022/11/30 03:11
linux-4.14 KASAN: use-after-free Read in sysv_new_block C 1 410d 494d 0/1 upstream: reported C repro on 2022/12/08 01:50
Last patch testing requests (10)
Created Duration User Patch Repo Result
2024/03/25 02:34 18m retest repro upstream report log
2024/03/25 02:34 18m retest repro upstream report log
2024/03/09 06:18 23m retest repro upstream OK log
2024/03/09 06:18 22m retest repro upstream OK log
2024/03/09 04:06 22m retest repro upstream OK log
2024/02/24 01:18 47m retest repro upstream OK log
2024/02/10 01:29 2h05m retest repro upstream OK log
2024/02/01 06:21 24m retest repro upstream OK log
2024/01/13 00:19 35m retest repro upstream OK log
2023/12/29 22:25 16m retest repro upstream report log
Fix bisection attempts (6)
Created Duration User Patch Repo Result
2024/02/01 08:56 5h52m (3) bisect fix upstream job log (1)
2023/08/09 16:46 3h16m bisect fix upstream job log (0) log
2023/06/07 16:03 57m bisect fix upstream job log (0) log
2023/05/08 15:00 40m bisect fix upstream job log (0) log
2023/03/29 14:31 50m bisect fix upstream job log (0) log
2023/02/27 14:00 28m bisect fix upstream job log (0) log

Sample crash report:
sysv_free_block: flc_count > flc_size
sysv_free_block: flc_count > flc_size
sysv_free_block: flc_count > flc_size
==================================================================
BUG: KASAN: use-after-free in sysv_new_block+0x7bb/0xa70 fs/sysv/balloc.c:113
Read of size 4 at addr ffff888030eb20c8 by task syz-executor805/5165

CPU: 2 PID: 5165 Comm: syz-executor805 Not tainted 6.8.0-rc7-syzkaller-00250-g137e0ec05aeb #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc4/0x620 mm/kasan/report.c:488
 kasan_report+0xda/0x110 mm/kasan/report.c:601
 sysv_new_block+0x7bb/0xa70 fs/sysv/balloc.c:113
 alloc_branch fs/sysv/itree.c:135 [inline]
 get_block+0x279/0x15c0 fs/sysv/itree.c:256
 __block_write_begin_int+0x4fb/0x16e0 fs/buffer.c:2103
 __block_write_begin fs/buffer.c:2152 [inline]
 block_write_begin+0xb1/0x4a0 fs/buffer.c:2211
 sysv_write_begin+0x31/0xe0 fs/sysv/itree.c:492
 generic_perform_write+0x273/0x620 mm/filemap.c:3930
 __generic_file_write_iter+0x1fd/0x240 mm/filemap.c:4025
 generic_file_write_iter+0xe7/0x350 mm/filemap.c:4051
 call_write_iter include/linux/fs.h:2087 [inline]
 new_sync_write fs/read_write.c:497 [inline]
 vfs_write+0x6de/0x1110 fs/read_write.c:590
 ksys_write+0x12f/0x260 fs/read_write.c:643
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x6f/0x77
RIP: 0033:0x7fdbf9b09359
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 1c 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fffff2150d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fdbf9b09359
RDX: 00000000fffffd5e RSI: 000000002000ad00 RDI: 0000000000000004
RBP: 00007fdbf9b8a720 R08: 00007fdbf9b4d53f R09: 00007fdbf9b4d53f
R10: 0000000000009e07 R11: 0000000000000246 R12: 00007fdbf9b4d004
R13: 00007fffff2151a8 R14: 00007fffff2151b0 R15: 00007fffff2151d0
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0000c3ac80 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x30eb2
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000000 ffffea0000c3acc8 ffffea0000be3848 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 5152, tgid 5152 (sshd), ts 43826954839, free_ts 43852381197
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x2d4/0x350 mm/page_alloc.c:1533
 prep_new_page mm/page_alloc.c:1540 [inline]
 get_page_from_freelist+0xa28/0x3780 mm/page_alloc.c:3311
 __alloc_pages+0x22c/0x2430 mm/page_alloc.c:4569
 alloc_pages_mpol+0x258/0x600 mm/mempolicy.c:2133
 vma_alloc_folio+0xad/0x220 mm/mempolicy.c:2172
 alloc_anon_folio mm/memory.c:4234 [inline]
 do_anonymous_page mm/memory.c:4292 [inline]
 do_pte_missing mm/memory.c:3743 [inline]
 handle_pte_fault mm/memory.c:5164 [inline]
 __handle_mm_fault+0x25ca/0x4920 mm/memory.c:5305
 handle_mm_fault+0x47a/0xa10 mm/memory.c:5470
 do_user_addr_fault+0x30b/0x1030 arch/x86/mm/fault.c:1355
 handle_page_fault arch/x86/mm/fault.c:1498 [inline]
 exc_page_fault+0x5d/0xc0 arch/x86/mm/fault.c:1554
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570
page last free pid 5152 tgid 5152 stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1140 [inline]
 free_unref_page_prepare+0x527/0xb10 mm/page_alloc.c:2346
 free_unref_page_list+0xe6/0xb40 mm/page_alloc.c:2532
 release_pages+0x32a/0x14f0 mm/swap.c:1042
 tlb_batch_pages_flush+0x9a/0x190 mm/mmu_gather.c:98
 tlb_flush_mmu_free mm/mmu_gather.c:293 [inline]
 tlb_flush_mmu mm/mmu_gather.c:300 [inline]
 tlb_finish_mmu+0x14b/0x700 mm/mmu_gather.c:392
 unmap_region+0x342/0x420 mm/mmap.c:2319
 do_vmi_align_munmap+0x11b3/0x1ad0 mm/mmap.c:2635
 do_vmi_munmap+0x20e/0x450 mm/mmap.c:2703
 __vm_munmap+0x146/0x3a0 mm/mmap.c:2990
 __do_sys_munmap mm/mmap.c:3007 [inline]
 __se_sys_munmap mm/mmap.c:3004 [inline]
 __x64_sys_munmap+0x62/0x90 mm/mmap.c:3004
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x6f/0x77

Memory state around the buggy address:
 ffff888030eb1f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888030eb2000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888030eb2080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                              ^
 ffff888030eb2100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888030eb2180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (13):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/03/11 02:12 upstream 137e0ec05aeb 6ee49f2e .config console log report syz C [disk image (non-bootable)] [vmlinux] [kernel image] [mounted in repro] ci-qemu-upstream KASAN: use-after-free Read in sysv_new_block
2024/03/10 09:02 upstream 005f6f34bd47 6ee49f2e .config console log report syz C [disk image (non-bootable)] [vmlinux] [kernel image] [mounted in repro] ci-qemu-upstream KASAN: use-after-free Read in sysv_new_block
2023/06/22 12:15 upstream dad9774deaf1 09ffe269 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in sysv_new_block
2023/06/20 16:09 upstream 692b7dc87ca6 09ffe269 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in sysv_new_block
2023/03/31 19:23 upstream 62bad54b26db f325deb0 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in sysv_new_block
2023/03/30 09:34 upstream ffe78bbd5121 f325deb0 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in sysv_new_block
2022/12/22 02:29 upstream ec34c2b4ec38 4067838e .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-root KASAN: use-after-free Read in sysv_new_block
2022/12/19 02:51 upstream f9ff5644bcc0 05494336 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-root KASAN: use-after-free Read in sysv_new_block
2022/11/30 22:39 upstream 01f856ae6d0c 4c2a66e8 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: use-after-free Read in sysv_new_block
2023/07/05 23:08 upstream d528014517f2 ba5dba36 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in sysv_new_block
2023/04/08 14:59 upstream aa318c48808c 71147e29 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in sysv_new_block
2023/01/27 19:35 upstream 7c46948a6e9c 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in sysv_new_block
2023/01/10 05:50 upstream 1fe4fd6f5cad 48bc529a .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in sysv_new_block
* Struck through repros no longer work on HEAD.