bcachefs (loop2): mounting version 1.7: mi_btree_bitmap opts=metadata_checksum=none,data_checksum=none,compression=lz4,nojournal_transaction_names
bcachefs (loop2): recovering from clean shutdown, journal seq 13
==================================================================
BUG: KASAN: use-after-free in memcpy_dir crypto/scatterwalk.c:23 [inline]
BUG: KASAN: use-after-free in scatterwalk_copychunks+0x1cc/0x460 crypto/scatterwalk.c:38
Read of size 40 at addr ffff88806d860000 by task syz.2.90/5728

CPU: 1 PID: 5728 Comm: syz.2.90 Not tainted 6.10.0-rc6-syzkaller-00061-ge9d22f7a6655 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189
 __asan_memcpy+0x29/0x70 mm/kasan/shadow.c:105
 memcpy_dir crypto/scatterwalk.c:23 [inline]
 scatterwalk_copychunks+0x1cc/0x460 crypto/scatterwalk.c:38
 skcipher_next_slow+0x39d/0x480 crypto/skcipher.c:276
 skcipher_walk_next+0x634/0xba0 crypto/skcipher.c:361
 chacha_simd_stream_xor+0x67f/0xd10 arch/x86/crypto/chacha_glue.c:192
 do_encrypt_sg fs/bcachefs/checksum.c:108 [inline]
 do_encrypt+0x4ef/0x7d0 fs/bcachefs/checksum.c:128
 bset_encrypt fs/bcachefs/btree_io.h:118 [inline]
 bch2_btree_node_read_done+0x185b/0x6750 fs/bcachefs/btree_io.c:1129
 btree_node_read_work+0x68b/0x1260 fs/bcachefs/btree_io.c:1345
 bch2_btree_node_read+0x2433/0x2a10
 __bch2_btree_root_read fs/bcachefs/btree_io.c:1769 [inline]
 bch2_btree_root_read+0x61e/0x970 fs/bcachefs/btree_io.c:1793
 read_btree_roots+0x22d/0x7c0 fs/bcachefs/recovery.c:481
 bch2_fs_recovery+0x235c/0x3730 fs/bcachefs/recovery.c:809
 bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1035
 bch2_fs_open+0xa8d/0xdf0 fs/bcachefs/super.c:2132
 bch2_mount+0x6b0/0x13a0 fs/bcachefs/fs.c:1926
 legacy_get_tree+0xee/0x190 fs/fs_context.c:662
 vfs_get_tree+0x90/0x2a0 fs/super.c:1789
 do_new_mount+0x2be/0xb40 fs/namespace.c:3352
 do_mount fs/namespace.c:3692 [inline]
 __do_sys_mount fs/namespace.c:3898 [inline]
 __se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3875
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fe0fe77729a
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 7e 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:00007fe0fe1fee78 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fe0fe1fef00 RCX: 00007fe0fe77729a
RDX: 000000002000f640 RSI: 000000002000f680 RDI: 00007fe0fe1feec0
RBP: 000000002000f640 R08: 00007fe0fe1fef00 R09: 0000000000200012
R10: 0000000000200012 R11: 0000000000000206 R12: 000000002000f680
R13: 00007fe0fe1feec0 R14: 000000000000f626 R15: 00000000200004c0
 </TASK>

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x6d860
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffefff(slab)
raw: 00fff00000000040 ffff888015eee8c0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000070007 00000001ffffefff 0000000000000000
head: 00fff00000000040 ffff888015eee8c0 dead000000000122 0000000000000000
head: 0000000000000000 0000000000070007 00000001ffffefff 0000000000000000
head: 00fff00000000003 ffffea0001b61801 ffffffffffffffff 0000000000000000
head: 0000000000000008 0000000000000000 00000000ffffffff 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4532, tgid 4532 (udevd), ts 118650305991, free_ts 118477379858
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1473
 prep_new_page mm/page_alloc.c:1481 [inline]
 get_page_from_freelist+0x2e4c/0x2f10 mm/page_alloc.c:3425
 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4683
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 alloc_slab_page+0x5f/0x120 mm/slub.c:2265
 allocate_slab+0x5a/0x2f0 mm/slub.c:2428
 new_slab mm/slub.c:2481 [inline]
 ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3667
 __slab_alloc+0x58/0xa0 mm/slub.c:3757
 __slab_alloc_node mm/slub.c:3810 [inline]
 slab_alloc_node mm/slub.c:3990 [inline]
 kmem_cache_alloc_noprof+0x1c1/0x2a0 mm/slub.c:4009
 getname_flags+0xbd/0x4f0 fs/namei.c:139
 user_path_at_empty+0x2c/0x60 fs/namei.c:2928
 do_readlinkat+0x118/0x3b0 fs/stat.c:499
 __do_sys_readlink fs/stat.c:532 [inline]
 __se_sys_readlink fs/stat.c:529 [inline]
 __x64_sys_readlink+0x7f/0x90 fs/stat.c:529
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 5728 tgid 5727 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1093 [inline]
 __free_pages_ok+0xb46/0xcb0 mm/page_alloc.c:1213
 __folio_put+0x3b9/0x620 mm/swap.c:129
 folio_put include/linux/mm.h:1513 [inline]
 free_large_kmalloc+0x105/0x1c0 mm/slub.c:4530
 kfree+0x1c4/0x360 mm/slub.c:4553
 btree_bounce_free fs/bcachefs/btree_io.c:118 [inline]
 bch2_btree_node_read_done+0x3e8f/0x6750 fs/bcachefs/btree_io.c:1220
 btree_node_read_work+0x68b/0x1260 fs/bcachefs/btree_io.c:1345
 bch2_btree_node_read+0x2433/0x2a10
 __bch2_btree_root_read fs/bcachefs/btree_io.c:1769 [inline]
 bch2_btree_root_read+0x61e/0x970 fs/bcachefs/btree_io.c:1793
 read_btree_roots+0x22d/0x7c0 fs/bcachefs/recovery.c:481
 bch2_fs_recovery+0x235c/0x3730 fs/bcachefs/recovery.c:809
 bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1035
 bch2_fs_open+0xa8d/0xdf0 fs/bcachefs/super.c:2132
 bch2_mount+0x6b0/0x13a0 fs/bcachefs/fs.c:1926
 legacy_get_tree+0xee/0x190 fs/fs_context.c:662
 vfs_get_tree+0x90/0x2a0 fs/super.c:1789
 do_new_mount+0x2be/0xb40 fs/namespace.c:3352

Memory state around the buggy address:
 ffff88806d85ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88806d85ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88806d860000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88806d860080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88806d860100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================