syzbot


KASAN: use-after-free Read in z_erofs_transform_plain

Status: upstream: reported C repro on 2024/02/07 05:17
Bug presence: origin:lts-only
[Documentation on labels]
Reported-by: syzbot+005786927870d2b071d4@syzkaller.appspotmail.com
First crash: 318d, last: 11d
Fix bisection: the issue occurs on the latest tested release (bisect log)
Crash: KASAN: use-after-free Read in z_erofs_transform_plain (log)
Repro: C syz .config
  
Bug presence (2)
Date Name Commit Repro Result
2024/02/08 linux-6.1.y (ToT) f1bb70486c9c C [report] KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2024/02/08 upstream (ToT) 047371968ffc C Didn't crash
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in z_erofs_transform_plain erofs C done 4 670d 747d 22/28 fixed on 2023/02/24 13:50
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2024/03/28 20:57 1h58m fix candidate upstream OK (0) job log
2024/03/26 21:49 3h01m bisect fix linux-6.1.y OK (0) job log log

Sample crash report:
loop0: detected capacity change from 0 to 16
erofs: (device loop0): mounted with root inode @ nid 36.
==================================================================
BUG: KASAN: use-after-free in z_erofs_transform_plain+0x375/0x470 fs/erofs/decompressor.c:356
Read of size 4096 at addr ffff8880761f0000 by task syz-executor338/3545

CPU: 1 PID: 3545 Comm: syz-executor338 Not tainted 6.1.77-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/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:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 kasan_check_range+0x27f/0x290 mm/kasan/generic.c:189
 memcpy+0x25/0x60 mm/kasan/shadow.c:65
 z_erofs_transform_plain+0x375/0x470 fs/erofs/decompressor.c:356
 z_erofs_decompress_pcluster fs/erofs/zdata.c:1173 [inline]
 z_erofs_decompress_queue+0x1aa0/0x2d50 fs/erofs/zdata.c:1256
 z_erofs_runqueue+0x1a6e/0x1ca0 fs/erofs/zdata.c:1614
 z_erofs_read_folio+0x478/0x760 fs/erofs/zdata.c:1709
 filemap_read_folio+0x199/0x780 mm/filemap.c:2461
 filemap_update_page mm/filemap.c:2546 [inline]
 filemap_get_pages mm/filemap.c:2660 [inline]
 filemap_read+0x1a13/0x31d0 mm/filemap.c:2730
 __kernel_read+0x41e/0x8a0 fs/read_write.c:428
 integrity_kernel_read+0xac/0xf0 security/integrity/iint.c:228
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:485 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:516 [inline]
 ima_calc_file_hash+0xa57/0x1c00 security/integrity/ima/ima_crypto.c:573
 ima_collect_measurement+0x59a/0xc30 security/integrity/ima/ima_api.c:293
 process_measurement+0x135c/0x21b0 security/integrity/ima/ima_main.c:351
 ima_file_check+0xed/0x170 security/integrity/ima/ima_main.c:534
 do_open fs/namei.c:3630 [inline]
 path_openat+0x2687/0x2e60 fs/namei.c:3785
 do_filp_open+0x230/0x480 fs/namei.c:3812
 do_sys_openat2+0x13b/0x500 fs/open.c:1318
 do_sys_open fs/open.c:1334 [inline]
 __do_sys_open fs/open.c:1342 [inline]
 __se_sys_open fs/open.c:1338 [inline]
 __x64_sys_open+0x221/0x270 fs/open.c:1338
 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:0x7f97a7073469
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 41 1a 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:00007ffcb6545018 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 0032656c69662f2e RCX: 00007f97a7073469
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000000
RBP: 00007f97a70b50cc R08: 0000000000000171 R09: 00007f97a70b50cc
R10: 00007ffcb6544ee0 R11: 0000000000000246 R12: 00007ffcb65451c0
R13: 00007f97a70b50e5 R14: 0000000000000001 R15: 0000000000000001
 </TASK>

Allocated by task 3515:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 __kasan_slab_alloc+0x65/0x70 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x10c/0x2d0 mm/slub.c:3422
 getname_flags+0xb8/0x4f0 fs/namei.c:139
 vfs_fstatat fs/stat.c:266 [inline]
 __do_sys_newfstatat fs/stat.c:437 [inline]
 __se_sys_newfstatat fs/stat.c:431 [inline]
 __x64_sys_newfstatat+0x130/0x1e0 fs/stat.c:431
 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

Freed by task 3515:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 kmem_cache_free+0x292/0x510 mm/slub.c:3683
 vfs_fstatat fs/stat.c:268 [inline]
 __do_sys_newfstatat fs/stat.c:437 [inline]
 __se_sys_newfstatat fs/stat.c:431 [inline]
 __x64_sys_newfstatat+0x15c/0x1e0 fs/stat.c:431
 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 ffff8880761f0000
 which belongs to the cache names_cache of size 4096
The buggy address is located 0 bytes inside of
 4096-byte region [ffff8880761f0000, ffff8880761f1000)

The buggy address belongs to the physical page:
page:ffffea0001d87c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x761f0
head:ffffea0001d87c00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888140009640
raw: 0000000000000000 0000000000070007 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3515, tgid 3515 (cmp), ts 52937082069, free_ts 52880876935
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2513
 prep_new_page mm/page_alloc.c:2520 [inline]
 get_page_from_freelist+0x31a1/0x3320 mm/page_alloc.c:4279
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5545
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xc20/0x1270 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x1a5/0x2d0 mm/slub.c:3422
 getname_flags+0xb8/0x4f0 fs/namei.c:139
 vfs_fstatat fs/stat.c:266 [inline]
 __do_sys_newfstatat fs/stat.c:437 [inline]
 __se_sys_newfstatat fs/stat.c:431 [inline]
 __x64_sys_newfstatat+0x130/0x1e0 fs/stat.c:431
 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
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1440 [inline]
 free_pcp_prepare mm/page_alloc.c:1490 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3358
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3453
 free_slab mm/slub.c:2031 [inline]
 discard_slab mm/slub.c:2037 [inline]
 __unfreeze_partials+0x1b7/0x210 mm/slub.c:2586
 put_cpu_partial+0x17b/0x250 mm/slub.c:2662
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x76/0xe0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x156/0x170 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x10c/0x2d0 mm/slub.c:3422
 getname_flags+0xb8/0x4f0 fs/namei.c:139
 do_sys_openat2+0xd2/0x500 fs/open.c:1312
 do_sys_open fs/open.c:1334 [inline]
 __do_sys_openat fs/open.c:1350 [inline]
 __se_sys_openat fs/open.c:1345 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1345
 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:
 ffff8880761eff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880761eff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880761f0000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8880761f0080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880761f0100: 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
2024/02/08 06:05 linux-6.1.y f1bb70486c9c 6404acf9 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2024/12/06 18:18 linux-6.1.y e4d90d63d385 946d28f0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2024/09/17 14:51 linux-6.1.y 5f55cad62cc9 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2024/09/17 14:08 linux-6.1.y 5f55cad62cc9 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2024/09/17 14:08 linux-6.1.y 5f55cad62cc9 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2024/09/15 15:39 linux-6.1.y 5f55cad62cc9 08d8a733 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2024/09/15 15:39 linux-6.1.y 5f55cad62cc9 08d8a733 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2024/09/15 06:45 linux-6.1.y 5f55cad62cc9 08d8a733 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2024/02/25 10:35 linux-6.1.y 81e1dc2f7001 8d446f15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2024/02/07 05:16 linux-6.1.y f1bb70486c9c 6404acf9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2024/12/10 10:58 linux-6.1.y e4d90d63d385 cfc402b4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in z_erofs_transform_plain
2024/12/06 15:41 linux-6.1.y e4d90d63d385 946d28f0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in z_erofs_transform_plain
2024/10/20 07:09 linux-6.1.y 54d90d17e8ce cd6fc0a3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in z_erofs_transform_plain
2024/09/17 10:28 linux-6.1.y 5f55cad62cc9 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in z_erofs_transform_plain
2024/09/15 09:52 linux-6.1.y 5f55cad62cc9 08d8a733 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in z_erofs_transform_plain
2024/12/06 18:19 linux-6.1.y e4d90d63d385 946d28f0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2024/12/10 10:58 linux-6.1.y e4d90d63d385 cfc402b4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2024/12/06 15:43 linux-6.1.y e4d90d63d385 946d28f0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2024/09/17 10:30 linux-6.1.y 5f55cad62cc9 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2024/09/15 09:52 linux-6.1.y 5f55cad62cc9 08d8a733 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
* Struck through repros no longer work on HEAD.