bcachefs (loop5): recovering from clean shutdown, journal seq 10 ================================================================== 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 32 at addr ffff888049280000 by task syz-executor.5/11797 CPU: 0 PID: 11797 Comm: syz-executor.5 Not tainted 6.10.0-rc3-syzkaller-00044-g2ccbdf43d5e7 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 Call Trace: __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+0x1ed6/0x6750 fs/bcachefs/btree_io.c:1088 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/0x7b0 fs/bcachefs/recovery.c:475 bch2_fs_recovery+0x2346/0x3720 fs/bcachefs/recovery.c:803 bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1035 bch2_fs_open+0xa8d/0xdf0 fs/bcachefs/super.c:2127 bch2_mount+0x6b0/0x13a0 fs/bcachefs/fs.c:1919 legacy_get_tree+0xf0/0x190 fs/fs_context.c:662 vfs_get_tree+0x92/0x2a0 fs/super.c:1780 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:0x7f080cc7e62a Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 09 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 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f080d9beef8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f080d9bef80 RCX: 00007f080cc7e62a RDX: 0000000020011a00 RSI: 0000000020011a40 RDI: 00007f080d9bef40 RBP: 0000000020011a00 R08: 00007f080d9bef80 R09: 0000000001200014 R10: 0000000001200014 R11: 0000000000000202 R12: 0000000020011a40 R13: 00007f080d9bef40 R14: 00000000000119fe R15: 00000000200001c0 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x49280 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffff7f(buddy) raw: 00fff00000000000 ffffea000117e008 ffffea0001060008 0000000000000000 raw: 0000000000000000 0000000000000007 00000000ffffff7f 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as freed page last allocated via order 7, migratetype Unmovable, gfp_mask 0x152cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 9240, tgid 9238 (syz-executor.3), ts 416548764018, free_ts 422261760390 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1468 prep_new_page mm/page_alloc.c:1476 [inline] get_page_from_freelist+0x2e43/0x2f00 mm/page_alloc.c:3420 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4678 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline] alloc_pages_node_noprof include/linux/gfp.h:296 [inline] __kmalloc_large_node+0x8b/0x1d0 mm/slub.c:4067 __do_kmalloc_node mm/slub.c:4110 [inline] __kmalloc_node_noprof+0x2d2/0x440 mm/slub.c:4129 kmalloc_node_noprof include/linux/slab.h:681 [inline] kvmalloc_node_noprof+0x72/0x190 mm/util.c:634 mempool_init_node+0x1f0/0x4e0 mm/mempool.c:217 mempool_init_noprof+0x3a/0x50 mm/mempool.c:246 mempool_init_kvmalloc_pool include/linux/mempool.h:105 [inline] __bch2_fs_compress_init+0x60e/0x9a0 fs/bcachefs/compress.c:625 bch2_fs_alloc+0x1dfe/0x2080 fs/bcachefs/super.c:926 bch2_fs_open+0x8cc/0xdf0 fs/bcachefs/super.c:2106 bch2_mount+0x6b0/0x13a0 fs/bcachefs/fs.c:1919 legacy_get_tree+0xf0/0x190 fs/fs_context.c:662 vfs_get_tree+0x92/0x2a0 fs/super.c:1780 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 page last free pid 9240 tgid 9238 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1088 [inline] __free_pages_ok+0xb4e/0xcc0 mm/page_alloc.c:1208 __folio_put+0x3b9/0x620 mm/swap.c:129 folio_put include/linux/mm.h:1508 [inline] free_large_kmalloc+0x105/0x1c0 mm/slub.c:4529 kfree+0x1c4/0x360 mm/slub.c:4552 mempool_exit+0xc9/0x1a0 mm/mempool.c:170 bch2_fs_compress_exit+0x4b/0x90 fs/bcachefs/compress.c:564 __bch2_fs_free fs/bcachefs/super.c:561 [inline] bch2_fs_release+0x23b/0x750 fs/bcachefs/super.c:605 kobject_cleanup lib/kobject.c:689 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x231/0x480 lib/kobject.c:737 bch2_fs_stop fs/bcachefs/super.c:675 [inline] bch2_fs_open+0xb57/0xdf0 fs/bcachefs/super.c:2143 bch2_mount+0x6b0/0x13a0 fs/bcachefs/fs.c:1919 legacy_get_tree+0xf0/0x190 fs/fs_context.c:662 vfs_get_tree+0x92/0x2a0 fs/super.c:1780 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 Memory state around the buggy address: ffff88804927ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88804927ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888049280000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff888049280080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888049280100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ==================================================================