================================================================== BUG: KASAN: use-after-free in memcpy_dir crypto/scatterwalk.c:23 [inline] BUG: KASAN: use-after-free in scatterwalk_copychunks+0x1dc/0x44c crypto/scatterwalk.c:38 Read of size 104 at addr ffff0000f1640000 by task syz.3.44/6555 CPU: 1 PID: 6555 Comm: syz.3.44 Not tainted 6.10.0-rc7-syzkaller-gc912bf709078 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 Call trace: dump_backtrace+0x1b8/0x1e4 arch/arm64/kernel/stacktrace.c:317 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:324 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:114 print_address_description mm/kasan/report.c:377 [inline] print_report+0x198/0x538 mm/kasan/report.c:488 kasan_report+0xd8/0x138 mm/kasan/report.c:601 kasan_check_range+0x268/0x2a8 mm/kasan/generic.c:189 __asan_memcpy+0x3c/0x84 mm/kasan/shadow.c:105 memcpy_dir crypto/scatterwalk.c:23 [inline] scatterwalk_copychunks+0x1dc/0x44c crypto/scatterwalk.c:38 skcipher_next_slow+0x210/0x3cc crypto/skcipher.c:276 skcipher_walk_next+0x548/0x9e0 crypto/skcipher.c:361 skcipher_walk_done+0x5e4/0x9d8 crypto/skcipher.c:157 chacha_neon_stream_xor+0x55c/0xc14 arch/arm64/crypto/chacha-neon-glue.c:132 chacha_neon+0x60/0x70 arch/arm64/crypto/chacha-neon-glue.c:143 crypto_skcipher_encrypt+0xfc/0x124 crypto/skcipher.c:643 do_encrypt_sg fs/bcachefs/checksum.c:108 [inline] do_encrypt+0x43c/0x6a0 fs/bcachefs/checksum.c:128 bch2_encrypt+0x8c/0xb0 fs/bcachefs/checksum.c:246 bset_encrypt fs/bcachefs/btree_io.h:118 [inline] bch2_btree_node_read_done+0x1064/0x4ac8 fs/bcachefs/btree_io.c:1129 btree_node_read_work+0x50c/0xe04 fs/bcachefs/btree_io.c:1345 bch2_btree_node_read+0x1f50/0x280c fs/bcachefs/btree_io.c:1730 __bch2_btree_root_read fs/bcachefs/btree_io.c:1769 [inline] bch2_btree_root_read+0x2a8/0x534 fs/bcachefs/btree_io.c:1793 read_btree_roots+0x21c/0x730 fs/bcachefs/recovery.c:481 bch2_fs_recovery+0x31c8/0x5488 fs/bcachefs/recovery.c:809 bch2_fs_start+0x30c/0x53c fs/bcachefs/super.c:1035 bch2_fs_open+0x8b4/0xb64 fs/bcachefs/super.c:2132 bch2_mount+0x4fc/0xe68 fs/bcachefs/fs.c:1926 legacy_get_tree+0xd4/0x16c fs/fs_context.c:662 vfs_get_tree+0x90/0x288 fs/super.c:1789 do_new_mount+0x278/0x900 fs/namespace.c:3352 path_mount+0x590/0xe04 fs/namespace.c:3679 do_mount fs/namespace.c:3692 [inline] __do_sys_mount fs/namespace.c:3898 [inline] __se_sys_mount fs/namespace.c:3875 [inline] __arm64_sys_mount+0x3c4/0x488 fs/namespace.c:3875 __invoke_syscall arch/arm64/kernel/syscall.c:34 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:131 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:150 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x131640 flags: 0x5ffc00000000000(node=0|zone=2|lastcpupid=0x7ff) page_type: 0xffffff7f(buddy) raw: 05ffc00000000000 fffffdffc3c1b808 ffff0001fea89cc8 0000000000000000 raw: 0000000000000000 0000000000000005 00000000ffffff7f 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff0000f163ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff0000f163ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff0000f1640000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff0000f1640080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff0000f1640100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== bcachefs (loop3): alloc_read... done bcachefs (loop3): stripes_read... done bcachefs (loop3): snapshots_read... done ------------[ cut here ]------------ kernel BUG at fs/bcachefs/btree_iter.c:640! Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP Modules linked in: CPU: 1 PID: 6555 Comm: syz.3.44 Tainted: G B 6.10.0-rc7-syzkaller-gc912bf709078 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : bch2_btree_path_level_init+0x810/0x83c fs/bcachefs/btree_iter.c:113 lr : btree_path_pos_in_node fs/bcachefs/btree_iter.c:113 [inline] lr : bch2_btree_path_level_init+0x810/0x83c fs/bcachefs/btree_iter.c:640 sp : ffff8000a1725330 x29: ffff8000a1725340 x28: dfff800000000000 x27: dda95647b7942cd0 x26: 24e09cbea5deef14 x25: 00000000208d05bc x24: 0000000000000000 x23: 0000000000000000 x22: 0000000000000000 x21: ffff0000cec7c2bc x20: ffff0000cd58e800 x19: ffff0000cec7c2b8 x18: ffff0001fea899d0 x17: ffff80008f0fd000 x16: ffff800082f8f174 x15: ffff7000142e4a54 x14: 1ffff000142e4a54 x13: 0000000000000004 x12: ffff8000a1725240 x11: 0000000000040000 x10: 000000000003ffff x9 : ffff8000a2b6f000 x8 : 0000000000040000 x7 : 0000000000000000 x6 : ffff8000827458fc x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000000000001 x2 : ffff0000cd58e800 x1 : dda95647b7942cd0 x0 : 0000000000000000 Call trace: btree_path_pos_in_node fs/bcachefs/btree_iter.c:113 [inline] bch2_btree_path_level_init+0x810/0x83c fs/bcachefs/btree_iter.c:640 btree_path_lock_root fs/bcachefs/btree_iter.c:778 [inline] bch2_btree_path_traverse_one+0xd88/0x2b7c fs/bcachefs/btree_iter.c:1177 bch2_btree_path_traverse fs/bcachefs/btree_iter.h:229 [inline] bch2_btree_iter_peek_slot+0x7e4/0x25e4 fs/bcachefs/btree_iter.c:2598 btree_key_cache_fill+0x14c/0xa84 fs/bcachefs/btree_key_cache.c:390 bch2_btree_path_traverse_cached_slowpath+0x33c/0x2140 fs/bcachefs/btree_key_cache.c:521 bch2_btree_path_traverse_cached+0x7b8/0xa24 bch2_btree_path_traverse_one+0x36c/0x2b7c fs/bcachefs/btree_iter.c:1153 bch2_btree_path_traverse fs/bcachefs/btree_iter.h:229 [inline] bch2_btree_iter_peek_slot+0x7e4/0x25e4 fs/bcachefs/btree_iter.c:2598 __bch2_bkey_get_iter fs/bcachefs/btree_iter.h:552 [inline] bch2_bkey_get_iter+0xe4/0x1bc fs/bcachefs/btree_iter.h:566 bch2_trans_start_alloc_update_noupdate+0xb8/0x50c fs/bcachefs/alloc_background.c:443 __bch2_trans_mark_metadata_bucket fs/bcachefs/buckets.c:1327 [inline] bch2_trans_mark_metadata_bucket+0x250/0xfc0 fs/bcachefs/buckets.c:1413 bch2_trans_mark_metadata_sectors fs/bcachefs/buckets.c:1430 [inline] __bch2_trans_mark_dev_sb fs/bcachefs/buckets.c:1465 [inline] bch2_trans_mark_dev_sb+0x2a4/0x614 fs/bcachefs/buckets.c:1493 bch2_trans_mark_dev_sbs_flags+0x754/0x7b4 fs/bcachefs/buckets.c:1503 bch2_trans_mark_dev_sbs+0x24/0x34 fs/bcachefs/buckets.c:1515 bch2_run_recovery_pass+0xe4/0x1d4 fs/bcachefs/recovery_passes.c:182 bch2_run_recovery_passes+0x258/0x6e0 fs/bcachefs/recovery_passes.c:225 bch2_fs_recovery+0x31f0/0x5488 fs/bcachefs/recovery.c:813 bch2_fs_start+0x30c/0x53c fs/bcachefs/super.c:1035 bch2_fs_open+0x8b4/0xb64 fs/bcachefs/super.c:2132 bch2_mount+0x4fc/0xe68 fs/bcachefs/fs.c:1926 legacy_get_tree+0xd4/0x16c fs/fs_context.c:662 vfs_get_tree+0x90/0x288 fs/super.c:1789 do_new_mount+0x278/0x900 fs/namespace.c:3352 path_mount+0x590/0xe04 fs/namespace.c:3679 do_mount fs/namespace.c:3692 [inline] __do_sys_mount fs/namespace.c:3898 [inline] __se_sys_mount fs/namespace.c:3875 [inline] __arm64_sys_mount+0x3c4/0x488 fs/namespace.c:3875 __invoke_syscall arch/arm64/kernel/syscall.c:34 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:131 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:150 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598 Code: d4210000 9778c84f d4210000 9778c84d (d4210000) ---[ end trace 0000000000000000 ]---