BUG: spinlock bad magic in btrfs_encoded_read_endio

Status: upstream: reported on 2026/03/20 05:11
Reported-by: syzbot+7f7402e6db0d5687291e@syzkaller.appspotmail.com
First crash: 181d, last: 1d02h
Similar bugs (5)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 BUG: spinlock bad magic in release_metapage origin:upstream 19 syz, C error 95 13d 731d 0/3 upstream: reported C repro on 2024/09/15 11:43
upstream BUG: spinlock bad magic in gadget_dev_open prio:normal usb 4 11 4d00h 35d 0/29 upstream: reported on 2026/08/12 22:54
linux-6.6 BUG: spinlock bad magic in release_metapage origin:upstream 4 syz, C error 11 102d 295d 0/2 upstream: reported C repro on 2025/11/25 20:12
linux-6.1 BUG: spinlock bad magic in release_metapage origin:upstream 4 syz, C error 92 3d08h 713d 0/3 upstream: reported C repro on 2024/10/04 04:01
upstream BUG: spinlock bad magic in release_metapage prio:high jfs 15 syz, C inconclusive 876 3d09h 737d 0/29 upstream: reported C repro on 2024/09/10 08:16

Sample crash report:
BUG: spinlock bad magic on CPU#0, kworker/u4:9/6299
==================================================================
BUG: KASAN: stack-out-of-bounds in spin_dump+0x157/0x1a0 kernel/locking/spinlock_debug.c:65
Read of size 4 at addr ffffc90004057854 by task kworker/u4:9/6299

CPU: 0 PID: 6299 Comm: kworker/u4:9 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Workqueue: btrfs-endio btrfs_end_bio_work
Call Trace:
 <TASK>
 dump_stack_lvl+0x188/0x24e lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0xa8/0x210 mm/kasan/report.c:420
 kasan_report+0x10b/0x140 mm/kasan/report.c:524
 spin_dump+0x157/0x1a0 kernel/locking/spinlock_debug.c:65
 spin_bug kernel/locking/spinlock_debug.c:77 [inline]
 debug_spin_lock_before kernel/locking/spinlock_debug.c:85 [inline]
 do_raw_spin_lock+0x1de/0x2f0 kernel/locking/spinlock_debug.c:114
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:111 [inline]
 _raw_spin_lock_irqsave+0xbc/0x100 kernel/locking/spinlock.c:162
 __wake_up_common_lock kernel/sched/wait.c:137 [inline]
 __wake_up+0x107/0x1a0 kernel/sched/wait.c:160
 btrfs_encoded_read_endio+0x500/0x640 fs/btrfs/inode.c:10646
 process_one_work+0x8ab/0x1160 kernel/workqueue.c:2292
 worker_thread+0xaf5/0x12a0 kernel/workqueue.c:2439
 kthread+0x29d/0x330 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>

The buggy address belongs to a 8-page vmalloc region starting at 0xffffc90004050000 allocated at copy_process+0x621/0x4070 kernel/fork.c:2192
The buggy address belongs to the physical page:
page:ffffea000175e3c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5d78f
memcg:ffff88802313b482
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000001ffffffff ffff88802313b482
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x102dc2(GFP_HIGHUSER|__GFP_NOWARN|__GFP_ZERO), pid 4282, tgid 4282 (syz-executor), ts 186272911424, free_ts 185934971619
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x173/0x1a0 mm/page_alloc.c:2560
 prep_new_page mm/page_alloc.c:2567 [inline]
 get_page_from_freelist+0x206b/0x2180 mm/page_alloc.c:4358
 __alloc_pages+0x1ec/0x4f0 mm/page_alloc.c:5658
 vm_area_alloc_pages mm/vmalloc.c:3059 [inline]
 __vmalloc_area_node mm/vmalloc.c:3128 [inline]
 __vmalloc_node_range+0x94a/0x1380 mm/vmalloc.c:3300
 alloc_thread_stack_node kernel/fork.c:313 [inline]
 dup_task_struct+0x3c8/0x700 kernel/fork.c:995
 copy_process+0x621/0x4070 kernel/fork.c:2192
 kernel_clone+0x24b/0x900 kernel/fork.c:2765
 __do_sys_clone kernel/fork.c:2906 [inline]
 __se_sys_clone kernel/fork.c:2890 [inline]
 __x64_sys_clone+0x1a7/0x220 kernel/fork.c:2890
 do_syscall_x64 arch/x86/entry/common.c:46 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:76
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1487 [inline]
 free_pcp_prepare mm/page_alloc.c:1537 [inline]
 free_unref_page_prepare+0x8e5/0x9e0 mm/page_alloc.c:3414
 free_unref_page_list+0xbb/0x8e0 mm/page_alloc.c:3555
 release_pages+0x20d1/0x2340 mm/swap.c:1035
 tlb_batch_pages_flush mm/mmu_gather.c:60 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:255 [inline]
 tlb_flush_mmu+0x105/0x220 mm/mmu_gather.c:262
 tlb_finish_mmu+0xf0/0x220 mm/mmu_gather.c:394
 exit_mmap+0x388/0x970 mm/mmap.c:3262
 __mmput+0x118/0x3a0 kernel/fork.c:1210
 exit_mm+0x24d/0x350 kernel/exit.c:572
 do_exit+0x958/0x2570 kernel/exit.c:874
 do_group_exit+0x229/0x2e0 kernel/exit.c:1030
 get_signal+0x1259/0x1340 kernel/signal.c:2884
 arch_do_signal_or_restart+0xc4/0x1310 arch/x86/kernel/signal.c:871
 exit_to_user_mode_loop+0x70/0x110 kernel/entry/common.c:177
 exit_to_user_mode_prepare+0xee/0x180 kernel/entry/common.c:213
 __syscall_exit_to_user_mode_work kernel/entry/common.c:295 [inline]
 syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:306
 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:82

Memory state around the buggy address:
 ffffc90004057700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffffc90004057780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffffc90004057800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                                 ^
 ffffc90004057880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffffc90004057900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/09/16 06:37 linux-6.1.y 1a8763b93150 12a0a44a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan BUG: spinlock bad magic in btrfs_encoded_read_endio
2026/06/24 14:48 linux-6.1.y fdb6fcb41cc7 302586aa .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan BUG: spinlock bad magic in btrfs_encoded_read_endio
2026/03/20 17:50 linux-6.1.y f2ddafa93a25 ac6f1dff .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan BUG: spinlock bad magic in btrfs_encoded_read_endio
2026/03/20 05:10 linux-6.1.y f2ddafa93a25 2f245add .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan BUG: spinlock bad magic in btrfs_encoded_read_endio
2026/05/16 19:09 linux-6.1.y c27210688955 a15a64a6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 BUG: spinlock bad magic in btrfs_encoded_read_endio
2026/05/06 13:23 linux-6.1.y 4931e0e1673d 1dddfd3d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 BUG: spinlock bad magic in btrfs_encoded_read_endio
* Struck through repros no longer work on HEAD.