bcachefs (loop4): recovering from clean shutdown, journal seq 13 ================================================================== BUG: KASAN: slab-use-after-free in memcpy_dir crypto/scatterwalk.c:23 [inline] BUG: KASAN: slab-use-after-free in scatterwalk_copychunks+0x1dc/0x44c crypto/scatterwalk.c:38 Read of size 104 at addr ffff0000f0560000 by task syz.4.363/7843 CPU: 0 PID: 7843 Comm: syz.4.363 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 Allocated by task 5903: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x40/0x78 mm/kasan/common.c:68 kasan_save_alloc_info+0x40/0x50 mm/kasan/generic.c:565 poison_kmalloc_redzone mm/kasan/common.c:370 [inline] __kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:387 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slub.c:4123 [inline] __kmalloc_noprof+0x2a0/0x494 mm/slub.c:4136 kmalloc_noprof include/linux/slab.h:664 [inline] tomoyo_realpath_from_path+0xc8/0x4cc security/tomoyo/realpath.c:251 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x218/0x588 security/tomoyo/file.c:822 tomoyo_inode_getattr+0x28/0x38 security/tomoyo/tomoyo.c:123 security_inode_getattr+0xd8/0x124 security/security.c:2269 vfs_getattr fs/stat.c:173 [inline] vfs_fstat fs/stat.c:198 [inline] vfs_fstatat+0x134/0x1b8 fs/stat.c:300 __do_sys_newfstatat fs/stat.c:468 [inline] __se_sys_newfstatat fs/stat.c:462 [inline] __arm64_sys_newfstatat+0x114/0x19c fs/stat.c:462 __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 Freed by task 5903: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x40/0x78 mm/kasan/common.c:68 kasan_save_free_info+0x54/0x6c mm/kasan/generic.c:579 poison_slab_object+0x128/0x180 mm/kasan/common.c:240 __kasan_slab_free+0x3c/0x70 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2196 [inline] slab_free mm/slub.c:4438 [inline] kfree+0x154/0x3e0 mm/slub.c:4559 tomoyo_realpath_from_path+0x484/0x4cc security/tomoyo/realpath.c:286 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x218/0x588 security/tomoyo/file.c:822 tomoyo_inode_getattr+0x28/0x38 security/tomoyo/tomoyo.c:123 security_inode_getattr+0xd8/0x124 security/security.c:2269 vfs_getattr fs/stat.c:173 [inline] vfs_fstat fs/stat.c:198 [inline] vfs_fstatat+0x134/0x1b8 fs/stat.c:300 __do_sys_newfstatat fs/stat.c:468 [inline] __se_sys_newfstatat fs/stat.c:462 [inline] __arm64_sys_newfstatat+0x114/0x19c fs/stat.c:462 __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 object at ffff0000f0560000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 0 bytes inside of freed 4096-byte region [ffff0000f0560000, ffff0000f0561000) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x130560 head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x5ffc00000000040(head|node=0|zone=2|lastcpupid=0x7ff) page_type: 0xffffefff(slab) raw: 05ffc00000000040 ffff0000c0002140 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000040004 00000001ffffefff 0000000000000000 head: 05ffc00000000040 ffff0000c0002140 dead000000000122 0000000000000000 head: 0000000000000000 0000000000040004 00000001ffffefff 0000000000000000 head: 05ffc00000000003 fffffdffc3c15801 ffffffffffffffff 0000000000000000 head: 0000000000000008 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff0000f055ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff0000f055ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff0000f0560000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff0000f0560080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff0000f0560100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== bcachefs (loop4): alloc_read... done bcachefs (loop4): stripes_read... done bcachefs (loop4): snapshots_read... done bcachefs (loop4): journal_replay... done bcachefs (loop4): resume_logged_ops... done bcachefs (loop4): going read-write bcachefs (loop4): done starting filesystem