syzbot


KASAN: use-after-free Read in sysv_new_block

Status: upstream: reported on 2024/10/28 12:55
Reported-by: syzbot+9aec3b4fc9b5eac66815@syzkaller.appspotmail.com
First crash: 91d, last: 2d08h
Similar bugs (4)
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 760d 790d 0/1 upstream: reported C repro on 2022/11/30 03:11
upstream KASAN: use-after-free Read in sysv_new_block fs C error done 521 18h09m 788d 0/28 upstream: reported C repro on 2022/12/01 12:49
linux-5.15 KASAN: use-after-free Read in sysv_new_block origin:upstream C 33 21h44m 99d 0/3 upstream: reported C repro on 2024/10/20 05:31
linux-4.14 KASAN: use-after-free Read in sysv_new_block C 1 697d 782d 0/1 upstream: reported C repro on 2022/12/08 01:50

Sample crash report:
syz.4.92: attempt to access beyond end of device
loop4: rw=0, sector=6491536, nr_sectors = 2 limit=128
Buffer I/O error on dev loop4, logical block 3245768, async page read
==================================================================
BUG: KASAN: use-after-free in sysv_new_block+0x788/0x960 fs/sysv/balloc.c:113
Read of size 4 at addr ffff888052c8e0c8 by task syz.4.92/4720

CPU: 1 PID: 4720 Comm: syz.4.92 Not tainted 6.1.126-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:427
 kasan_report+0x136/0x160 mm/kasan/report.c:531
 sysv_new_block+0x788/0x960 fs/sysv/balloc.c:113
 alloc_branch fs/sysv/itree.c:134 [inline]
 get_block+0x2e7/0x1790 fs/sysv/itree.c:253
 __block_write_begin_int+0x544/0x1a30 fs/buffer.c:1991
 __block_write_begin fs/buffer.c:2041 [inline]
 block_write_begin+0x98/0x1f0 fs/buffer.c:2102
 sysv_write_begin+0x2d/0x60 fs/sysv/itree.c:487
 page_symlink+0x2c1/0x4e0 fs/namei.c:5218
 sysv_symlink+0xcb/0x180 fs/sysv/namei.c:86
 vfs_symlink+0x247/0x3d0 fs/namei.c:4471
 do_symlinkat+0x21e/0x390 fs/namei.c:4500
 __do_sys_symlink fs/namei.c:4522 [inline]
 __se_sys_symlink fs/namei.c:4520 [inline]
 __x64_sys_symlink+0x7a/0x90 fs/namei.c:4520
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f9a3ab85d29
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:00007f9a3baa0038 EFLAGS: 00000246 ORIG_RAX: 0000000000000058
RAX: ffffffffffffffda RBX: 00007f9a3ad75fa0 RCX: 00007f9a3ab85d29
RDX: 0000000000000000 RSI: 00000000200059c0 RDI: 0000000020002840
RBP: 00007f9a3ac01b08 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f9a3ad75fa0 R15: 00007fffa18ce428
 </TASK>

The buggy address belongs to the physical page:
page:ffffea00014b2380 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x52c8e
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea00014b23c8 ffffea00014b2348 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 0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), pid 4669, tgid 4668 (syz.3.82), ts 108000640832, free_ts 110587918375
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2532
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x3731/0x38d0 mm/page_alloc.c:4328
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5605
 __folio_alloc+0xf/0x30 mm/page_alloc.c:5637
 vma_alloc_folio+0x486/0x990 mm/mempolicy.c:2243
 shmem_alloc_folio mm/shmem.c:1589 [inline]
 shmem_alloc_and_acct_folio+0x5a8/0xd50 mm/shmem.c:1613
 shmem_get_folio_gfp+0x13f0/0x3470 mm/shmem.c:1941
 shmem_get_folio mm/shmem.c:2072 [inline]
 shmem_write_begin+0x16e/0x4e0 mm/shmem.c:2556
 generic_perform_write+0x2fc/0x5e0 mm/filemap.c:3845
 __generic_file_write_iter+0x176/0x400 mm/filemap.c:3973
 generic_file_write_iter+0xab/0x310 mm/filemap.c:4005
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x857/0xbc0 fs/read_write.c:584
 ksys_write+0x19c/0x2c0 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare mm/page_alloc.c:1509 [inline]
 free_unref_page_prepare+0x12a6/0x15b0 mm/page_alloc.c:3384
 free_unref_page_list+0x663/0x900 mm/page_alloc.c:3525
 release_pages+0x24c4/0x27a0 mm/swap.c:1035
 __pagevec_release+0x80/0xf0 mm/swap.c:1055
 pagevec_release include/linux/pagevec.h:71 [inline]
 folio_batch_release include/linux/pagevec.h:135 [inline]
 shmem_undo_range+0x865/0x2390 mm/shmem.c:946
 shmem_truncate_range mm/shmem.c:1062 [inline]
 shmem_evict_inode+0x265/0xa60 mm/shmem.c:1171
 evict+0x529/0x930 fs/inode.c:705
 do_unlinkat+0x509/0x820 fs/namei.c:4397
 __do_sys_unlink fs/namei.c:4438 [inline]
 __se_sys_unlink fs/namei.c:4436 [inline]
 __x64_sys_unlink+0x45/0x50 fs/namei.c:4436
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Memory state around the buggy address:
 ffff888052c8df80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888052c8e000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888052c8e080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                              ^
 ffff888052c8e100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888052c8e180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (17):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/23 02:13 linux-6.1.y f4f677285b38 a44b0418 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2025/01/23 02:11 linux-6.1.y f4f677285b38 a44b0418 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2025/01/21 17:40 linux-6.1.y f4f677285b38 da72ac06 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2025/01/21 17:39 linux-6.1.y f4f677285b38 da72ac06 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2025/01/20 10:44 linux-6.1.y f4f677285b38 f2cb035c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2025/01/19 23:17 linux-6.1.y f4f677285b38 f2cb035c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2025/01/05 23:06 linux-6.1.y 7dc732d24ff7 f3558dbf .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2024/12/11 18:47 linux-6.1.y e4d90d63d385 ff949d25 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2024/12/11 18:44 linux-6.1.y e4d90d63d385 ff949d25 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2024/12/02 03:04 linux-6.1.y e4d90d63d385 68914665 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2024/11/30 01:36 linux-6.1.y e4d90d63d385 68914665 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2024/11/30 01:35 linux-6.1.y e4d90d63d385 68914665 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2024/11/25 01:10 linux-6.1.y e4d90d63d385 68da6d95 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2024/11/19 06:31 linux-6.1.y b67dc5c9ade9 571351cb .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2024/10/28 12:54 linux-6.1.y 7ec6f9fa3d97 65e8686b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in sysv_new_block
2025/01/25 19:38 linux-6.1.y 75cefdf153f5 9fbd772e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in sysv_new_block
2025/01/20 16:45 linux-6.1.y f4f677285b38 6e87cfa2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in sysv_new_block
* Struck through repros no longer work on HEAD.