syzbot


KASAN: stack-out-of-bounds Read in do_encrypt

Status: upstream: reported on 2024/11/18 12:15
Subsystems: bcachefs
[Documentation on labels]
Reported-by: syzbot+1e42728e2fb48752d6f2@syzkaller.appspotmail.com
First crash: 139d, last: 5d19h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [bcachefs?] KASAN: stack-out-of-bounds Read in do_encrypt 0 (1) 2024/11/18 12:15

Sample crash report:
loop0: detected capacity change from 0 to 32768
bcachefs (loop0): starting version 1.7: mi_btree_bitmap opts=metadata_checksum=none,data_checksum=none,compression=lz4,metadata_target=invalid device 255,noinodes_use_key_cache,journal_flush_delay=1001,nojournal_transaction_names
bcachefs (loop0): recovering from clean shutdown, journal seq 13
bcachefs (loop0): Version upgrade required:
Version upgrade from 0.19: freespace to 1.7: mi_btree_bitmap incomplete
Doing incompatible version upgrade from 0.19: freespace to 1.25: extent_flags
  running recovery passes: check_allocations,check_alloc_info,check_lrus,check_btree_backpointers,check_backpointers_to_extents,check_extents_to_backpointers,check_alloc_to_lru_refs,bucket_gens_init,check_snapshot_trees,check_snapshots,check_subvols,check_subvol_children,delete_dead_snapshots,check_inodes,check_extents,check_indirect_extents,check_dirents,check_xattrs,check_root,check_unreachable_inodes,check_subvolume_structure,check_directory_structure,check_nlinks,set_fs_needs_rebalance
==================================================================
BUG: KASAN: stack-out-of-bounds in sg_mark_end include/linux/scatterlist.h:258 [inline]
BUG: KASAN: stack-out-of-bounds in do_encrypt+0xa1c/0xd70 fs/bcachefs/checksum.c:158
Read of size 8 at addr ffffc9000d546768 by task syz.0.0/5324

CPU: 0 UID: 0 PID: 5324 Comm: syz.0.0 Not tainted 6.14.0-syzkaller-07318-g4fa118e5b79f #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:408 [inline]
 print_report+0x16e/0x5b0 mm/kasan/report.c:521
 kasan_report+0x143/0x180 mm/kasan/report.c:634
 sg_mark_end include/linux/scatterlist.h:258 [inline]
 do_encrypt+0xa1c/0xd70 fs/bcachefs/checksum.c:158
 bset_encrypt fs/bcachefs/btree_io.h:119 [inline]
 bch2_btree_node_read_done+0x1e95/0x62d0 fs/bcachefs/btree_io.c:1115
 btree_node_read_work+0x6cb/0x1400 fs/bcachefs/btree_io.c:1365
 bch2_btree_node_read+0x2427/0x29e0 fs/bcachefs/btree_io.c:-1
 __bch2_btree_root_read fs/bcachefs/btree_io.c:1795 [inline]
 bch2_btree_root_read+0x656/0x7e0 fs/bcachefs/btree_io.c:1817
 read_btree_roots+0x3d7/0xa80 fs/bcachefs/recovery.c:581
 bch2_fs_recovery+0x28e4/0x3e20 fs/bcachefs/recovery.c:928
 bch2_fs_start+0x37c/0x620 fs/bcachefs/super.c:1057
 bch2_fs_get_tree+0x1270/0x18d0 fs/bcachefs/fs.c:2253
 vfs_get_tree+0x90/0x2b0 fs/super.c:1759
 do_new_mount+0x2cf/0xb70 fs/namespace.c:3878
 do_mount fs/namespace.c:4218 [inline]
 __do_sys_mount fs/namespace.c:4429 [inline]
 __se_sys_mount+0x38c/0x400 fs/namespace.c:4406
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5dbd78e90a
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 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:00007f5dbe668e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f5dbe668ef0 RCX: 00007f5dbd78e90a
RDX: 000020000000f640 RSI: 000020000000f680 RDI: 00007f5dbe668eb0
RBP: 000020000000f640 R08: 00007f5dbe668ef0 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000020000000f680
R13: 00007f5dbe668eb0 R14: 000000000000f62a R15: 0000200000000280
 </TASK>

The buggy address belongs to stack of task syz.0.0/5324
 and is located at offset 1768 in frame:
 do_encrypt+0x0/0xd70 fs/bcachefs/checksum.c:-1

This frame has 8 objects:
 [32, 48) 'nonce.i272'
 [64, 528) '__req_desc.i273'
 [592, 608) 'nonce.i254'
 [624, 1088) '__req_desc.i255'
 [1152, 1168) 'nonce.i'
 [1184, 1648) '__req_desc.i'
 [1712, 1744) 'sg'
 [1776, 1928) 'sgl'

The buggy address belongs to the virtual mapping at
 [ffffc9000d540000, ffffc9000d549000) created by:
 copy_process+0x5dc/0x3d10 kernel/fork.c:2225

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880411bbbd0 pfn:0x411bb
memcg:ffff888043598302
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
raw: 04fff00000000000 0000000000000000 dead000000000122 0000000000000000
raw: ffff8880411bbbd0 0000000000000000 00000001ffffffff ffff888043598302
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x2dc2(GFP_KERNEL|__GFP_HIGHMEM|__GFP_ZERO|__GFP_NOWARN), pid 5322, tgid 5322 (syz.0.0), ts 57191550398, free_ts 57087808937
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f4/0x240 mm/page_alloc.c:1551
 prep_new_page mm/page_alloc.c:1559 [inline]
 get_page_from_freelist+0x3695/0x37e0 mm/page_alloc.c:3477
 __alloc_frozen_pages_noprof+0x2c5/0x7b0 mm/page_alloc.c:4740
 alloc_pages_mpol+0x339/0x690 mm/mempolicy.c:2301
 alloc_frozen_pages_noprof mm/mempolicy.c:2372 [inline]
 alloc_pages_noprof+0x121/0x190 mm/mempolicy.c:2392
 vm_area_alloc_pages mm/vmalloc.c:3591 [inline]
 __vmalloc_area_node mm/vmalloc.c:3669 [inline]
 __vmalloc_node_range_noprof+0x9cb/0x1390 mm/vmalloc.c:3846
 alloc_thread_stack_node kernel/fork.c:314 [inline]
 dup_task_struct+0x444/0x8c0 kernel/fork.c:1127
 copy_process+0x5dc/0x3d10 kernel/fork.c:2225
 kernel_clone+0x242/0x930 kernel/fork.c:2810
 __do_sys_clone3 kernel/fork.c:3114 [inline]
 __se_sys_clone3+0x348/0x380 kernel/fork.c:3093
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 4725 tgid 4725 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1127 [inline]
 free_frozen_pages+0xe16/0x10f0 mm/page_alloc.c:2660
 __slab_free+0x2c6/0x390 mm/slub.c:4544
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x9a/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:329
 kasan_slab_alloc include/linux/kasan.h:250 [inline]
 slab_post_alloc_hook mm/slub.c:4138 [inline]
 slab_alloc_node mm/slub.c:4187 [inline]
 kmem_cache_alloc_lru_noprof+0x1e5/0x390 mm/slub.c:4206
 shmem_alloc_inode+0x28/0x40 mm/shmem.c:5160
 alloc_inode+0x69/0x1b0 fs/inode.c:346
 new_inode+0x22/0x180 fs/inode.c:1145
 __shmem_get_inode mm/shmem.c:3058 [inline]
 shmem_get_inode+0x39d/0xf20 mm/shmem.c:3132
 shmem_mknod+0x191/0x3d0 mm/shmem.c:3854
 lookup_open fs/namei.c:3666 [inline]
 open_last_lookups fs/namei.c:3765 [inline]
 path_openat+0x194b/0x35d0 fs/namei.c:4001
 do_filp_open+0x284/0x4e0 fs/namei.c:4031
 do_sys_openat2+0x12b/0x1d0 fs/open.c:1429
 do_sys_open fs/open.c:1444 [inline]
 __do_sys_openat fs/open.c:1460 [inline]
 __se_sys_openat fs/open.c:1455 [inline]
 __x64_sys_openat+0x249/0x2a0 fs/open.c:1455
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94

Memory state around the buggy address:
 ffffc9000d546600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffffc9000d546680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f2 f2
>ffffc9000d546700: f2 f2 f2 f2 f2 f2 00 00 00 00 f2 f2 f2 f2 00 00
                                                          ^
 ffffc9000d546780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffffc9000d546800: 00 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 00 00 00 00
==================================================================

Crashes (29):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/03/28 03:26 upstream 4fa118e5b79f 6c09fb82 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/03/24 05:31 upstream 586de92313fc 875573af .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/03/22 06:30 upstream d07de43e3f05 c6512ef7 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/03/19 20:13 upstream 81e4f8d68c66 8d0a2921 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/03/19 15:11 upstream 81e4f8d68c66 8d0a2921 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/03/19 14:00 upstream 81e4f8d68c66 8d0a2921 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/03/19 01:13 upstream 76b6905c11fd 22a6c2b1 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/03/15 09:38 upstream 83158b21ae9a e2826670 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/03/11 08:56 upstream 4d872d51bc9d 16256247 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/03/08 06:09 upstream 21e4543a2e2f 7e3bd60d .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/03/03 18:27 upstream 7eb172143d55 c3901742 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/02/25 12:30 upstream d082ecbc71e9 d34966d1 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/02/23 15:30 upstream 27102b38b8ca d34966d1 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/02/21 04:41 upstream e9a8cac0bf89 0808a665 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/02/07 22:12 upstream bb066fe812d6 a4f327c2 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/02/07 19:35 upstream bb066fe812d6 a4f327c2 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/02/05 13:41 upstream 5c8c229261f1 5896748e .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/02/03 08:30 upstream 69e858e0b8b2 568559e4 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/02/02 20:19 upstream 69e858e0b8b2 568559e4 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/02/01 00:13 upstream 69e858e0b8b2 aa47157c .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/01/30 09:52 upstream 805ba04cb7cc afe4eff5 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/01/29 19:11 upstream 805ba04cb7cc d03b0c97 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/01/29 08:46 upstream 805ba04cb7cc 865ef71e .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/01/24 10:57 upstream e0b1f5914274 521b0ce3 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/01/23 21:57 upstream 21266b8df522 f6a35ef3 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/01/16 11:00 upstream 619f0b6fad52 968edaf4 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/01/11 19:48 upstream 77a903cd8e5a 6dbc6a9b .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2025/01/03 10:24 upstream 0bc21e701a6f d3ccff63 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
2024/11/14 05:42 upstream 0a9b9d17f3a7 a8c99394 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in do_encrypt
* Struck through repros no longer work on HEAD.