BUG: sleeping function called from invalid context in kvm_mmu_notifier_invalidate_range_start
Subsystems (5)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: 37bb2e7217b0 Merge tag 'staging-6.19-rc1' of git://git.ker.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=159b2992580000 kernel config: https://syzkaller.appspot.com/x/.config?x=8750900a7c493a0b dashboard link: https://syzkaller.appspot.com/bug?extid=c3178b6b512446632bac compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
Unfortunately, I don't have any reproducer for this issue yet.
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/461486e4058d/disk-37bb2e72.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/844c0aeb98b9/vmlinux-37bb2e72.xz
kernel image: https://storage.googleapis.com/syzbot-assets/20fb43a5a012/bzImage-37bb2e72.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
in_atomic(): 0, irqs_disabled(): 0, non_block: 1, pid: 39, name: oom_reaperpreempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
4 locks held by oom_reaper/39:
#0: ffff888030a29070 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_trylock include/linux/mmap_lock.h:410 [inline]
#0: ffff888030a29070 (&mm->mmap_lock){++++}-{4:4}, at: oom_reap_task_mm mm/oom_kill.c:582 [inline]
#0: ffff888030a29070 (&mm->mmap_lock){++++}-{4:4}, at: oom_reap_task mm/oom_kill.c:625 [inline]
#0: ffff888030a29070 (&mm->mmap_lock){++++}-{4:4}, at: oom_reaper+0x27e/0xa90 mm/oom_kill.c:666
#1: ffffffff8d6ce600 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at: mmu_notifier_invalidate_range_start_nonblock include/linux/mmu_notifier.h:456 [inline] #1: ffffffff8d6ce600 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at: __oom_reap_task_mm+0x268/0x490 mm/oom_kill.c:558
#2: ffffffff8d6ce658 (srcu){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:185 [inline]
#2: ffffffff8d6ce658 (srcu){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:277 [inline]
#2: ffffffff8d6ce658 (srcu){.+.+}-{0:0}, at: mn_hlist_invalidate_range_start mm/mmu_notifier.c:468 [inline]
#2: ffffffff8d6ce658 (srcu){.+.+}-{0:0}, at: __mmu_notifier_invalidate_range_start+0x30b/0x840 mm/mmu_notifier.c:533
#3: ffff8880276bcaf8 (&kvm->mn_invalidate_lock){+.+.}-{3:3}, at: spin_lock include/linux/spinlock_rt.h:44 [inline]
#3: ffff8880276bcaf8 (&kvm->mn_invalidate_lock){+.+.}-{3:3}, at: kvm_mmu_notifier_invalidate_range_start+0x1bd/0xae0 virt/kvm/kvm_main.c:750
CPU: 1 UID: 0 PID: 39 Comm: oom_reaper Tainted: G L syzkaller #0 PREEMPT_{RT,(full)}
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025
Call Trace:
<TASK>
dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
__might_resched+0x44b/0x5d0 kernel/sched/core.c:8827
__rt_spin_lock kernel/locking/spinlock_rt.c:48 [inline]
rt_spin_lock+0xc7/0x3e0 kernel/locking/spinlock_rt.c:57
spin_lock include/linux/spinlock_rt.h:44 [inline]
kvm_mmu_notifier_invalidate_range_start+0x1bd/0xae0 virt/kvm/kvm_main.c:750
mn_hlist_invalidate_range_start mm/mmu_notifier.c:478 [inline]
__mmu_notifier_invalidate_range_start+0x440/0x840 mm/mmu_notifier.c:533
mmu_notifier_invalidate_range_start_nonblock include/linux/mmu_notifier.h:459 [inline]
__oom_reap_task_mm+0x2cb/0x490 mm/oom_kill.c:558
oom_reap_task_mm mm/oom_kill.c:601 [inline]
oom_reap_task mm/oom_kill.c:625 [inline]
oom_reaper+0x3aa/0xa90 mm/oom_kill.c:666
kthread+0x711/0x8a0 kernel/kthread.c:463
ret_from_fork+0x599/0xb30 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246
</TASK>oom_reaper: reaped process 20496 (syz.8.2014), now anon-rss:24kB, file-rss:21692kB, shmem-rss:128kB
---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
syzbot
syzbotsyzbot has found a reproducer for the following issue on:
syzbot has found a reproducer for the following issue on:
HEAD commit: b9303e6bff70 Add linux-next specific files for 20260430 git tree: linux-next console output: https://syzkaller.appspot.com/x/log.txt?x=13745dba580000 kernel config: https://syzkaller.appspot.com/x/.config?x=5474e13c6d20d45c dashboard link: https://syzkaller.appspot.com/bug?extid=c3178b6b512446632bac compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=125dd748580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b3a0a2e50f73/disk-b9303e6b.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d3d481b220d4/vmlinux-b9303e6b.xz
kernel image: https://storage.googleapis.com/syzbot-assets/d6e012913960/bzImage-b9303e6b.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
in_atomic(): 0, irqs_disabled(): 0, non_block: 1, pid: 40, name: oom_reaperpreempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
4 locks held by oom_reaper/40:
#0: ffff8880335ed1b0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_trylock include/linux/mmap_lock.h:611 [inline]
#0: ffff8880335ed1b0 (&mm->mmap_lock){++++}-{4:4}, at: oom_reap_task_mm mm/oom_kill.c:566 [inline]
#0: ffff8880335ed1b0 (&mm->mmap_lock){++++}-{4:4}, at: oom_reap_task mm/oom_kill.c:609 [inline]
#0: ffff8880335ed1b0 (&mm->mmap_lock){++++}-{4:4}, at: oom_reaper+0x2bb/0xc10 mm/oom_kill.c:650
#1: ffffffff8e3066c0 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at: mmu_notifier_invalidate_range_start_nonblock include/linux/mmu_notifier.h:495 [inline] #1: ffffffff8e3066c0 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at: zap_vma_for_reaping+0x193/0x380 mm/memory.c:2119
#2: ffffffff8e306718 (srcu){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:187 [inline]
#2: ffffffff8e306718 (srcu){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:294 [inline]
#2: ffffffff8e306718 (srcu){.+.+}-{0:0}, at: mn_hlist_invalidate_range_start mm/mmu_notifier.c:515 [inline]
#2: ffffffff8e306718 (srcu){.+.+}-{0:0}, at: __mmu_notifier_invalidate_range_start+0x5a1/0xb60 mm/mmu_notifier.c:580
#3: ffff88803996caf8 (&kvm->mn_invalidate_lock){+.+.}-{3:3}, at: spin_lock include/linux/spinlock_rt.h:45 [inline]
#3: ffff88803996caf8 (&kvm->mn_invalidate_lock){+.+.}-{3:3}, at: kvm_mmu_notifier_invalidate_range_start+0x1b7/0xc00 virt/kvm/kvm_main.c:744
CPU: 0 UID: 0 PID: 40 Comm: oom_reaper Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
__might_resched+0x329/0x480 kernel/sched/core.c:9163
__rt_spin_lock kernel/locking/spinlock_rt.c:48 [inline]
rt_spin_lock+0xc2/0x400 kernel/locking/spinlock_rt.c:57
spin_lock include/linux/spinlock_rt.h:45 [inline]
kvm_mmu_notifier_invalidate_range_start+0x1b7/0xc00 virt/kvm/kvm_main.c:744
mn_hlist_invalidate_range_start mm/mmu_notifier.c:525 [inline]
__mmu_notifier_invalidate_range_start+0x6e4/0xb60 mm/mmu_notifier.c:580
mmu_notifier_invalidate_range_start_nonblock include/linux/mmu_notifier.h:498 [inline]
zap_vma_for_reaping+0x1f7/0x380 mm/memory.c:2119
__oom_reap_task_mm mm/oom_kill.c:548 [inline]
oom_reap_task_mm mm/oom_kill.c:585 [inline]
oom_reap_task mm/oom_kill.c:609 [inline]
oom_reaper+0x51e/0xc10 mm/oom_kill.c:650
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48in_atomic(): 0, irqs_disabled(): 0, non_block: 1, pid: 40, name: oom_reaperpreempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
4 locks held by oom_reaper/40:
#0: ffff8880335ed1b0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_trylock include/linux/mmap_lock.h:611 [inline]
#0: ffff8880335ed1b0 (&mm->mmap_lock){++++}-{4:4}, at: oom_reap_task_mm mm/oom_kill.c:566 [inline]
#0: ffff8880335ed1b0 (&mm->mmap_lock){++++}-{4:4}, at: oom_reap_task mm/oom_kill.c:609 [inline]
#0: ffff8880335ed1b0 (&mm->mmap_lock){++++}-{4:4}, at: oom_reaper+0x2bb/0xc10 mm/oom_kill.c:650
#1: ffffffff8e3066c0 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at: __mmu_notifier_invalidate_range_end+0x67/0x400 mm/mmu_notifier.c:611 #2: ffffffff8e306718 (srcu){.+.+}-{0:0}, at: __mmu_notifier_invalidate_range_end+0x67/0x400 mm/mmu_notifier.c:611
#3: ffff88803996caf8 (&kvm->mn_invalidate_lock){+.+.}-{3:3}, at: spin_lock include/linux/spinlock_rt.h:45 [inline]
#3: ffff88803996caf8 (&kvm->mn_invalidate_lock){+.+.}-{3:3}, at: kvm_mmu_notifier_invalidate_range_end+0x1d6/0x3d0 virt/kvm/kvm_main.c:814
CPU: 0 UID: 0 PID: 40 Comm: oom_reaper Tainted: G W syzkaller #0 PREEMPT_{RT,(full)}
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
__might_resched+0x329/0x480 kernel/sched/core.c:9163
__rt_spin_lock kernel/locking/spinlock_rt.c:48 [inline]
rt_spin_lock+0xc2/0x400 kernel/locking/spinlock_rt.c:57
spin_lock include/linux/spinlock_rt.h:45 [inline]
kvm_mmu_notifier_invalidate_range_end+0x1d6/0x3d0 virt/kvm/kvm_main.c:814
mn_hlist_invalidate_end mm/mmu_notifier.c:597 [inline]
__mmu_notifier_invalidate_range_end+0x23b/0x400 mm/mmu_notifier.c:616
mmu_notifier_invalidate_range_end include/linux/mmu_notifier.h:511 [inline]
zap_vma_for_reaping+0x2d9/0x380 mm/memory.c:2124
__oom_reap_task_mm mm/oom_kill.c:548 [inline]
oom_reap_task_mm mm/oom_kill.c:585 [inline]
oom_reap_task mm/oom_kill.c:609 [inline]
oom_reaper+0x51e/0xc10 mm/oom_kill.c:650
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>oom_reaper: reaped process 6034 (syz.0.24), now anon-rss:0kB, file-rss:64kB, shmem-rss:0kB
---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
Sean Christopherson
reviewerQuoted 15 lines · syzbot
syzbot has found a reproducer for the following issue on:
HEAD commit: b9303e6bff70 Add linux-next specific files for 20260430 git tree: linux-next console output: https://syzkaller.appspot.com/x/log.txt?x=13745dba580000 kernel config: https://syzkaller.appspot.com/x/.config?x=5474e13c6d20d45c dashboard link: https://syzkaller.appspot.com/bug?extid=c3178b6b512446632bac compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=125dd748580000Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b3a0a2e50f73/disk-b9303e6b.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d3d481b220d4/vmlinux-b9303e6b.xz
kernel image: https://storage.googleapis.com/syzbot-assets/d6e012913960/bzImage-b9303e6b.xz
Quoted 4 lines
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by [email protected]BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
This is a known issue:
https://lore.kernel.org/all/[email protected]
Quoted 81 lines
in_atomic(): 0,irqs_disabled(): 0,non_block: 1, pid: 40, name:oom_reaperpreempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
4 locks held by oom_reaper/40:
#0:ffff8880335ed1b0(&mm->mmap_lock){++++}-{4:4}, at:mmap_read_trylockinclude/linux/mmap_lock.h:611[inline]
#0:ffff8880335ed1b0(&mm->mmap_lock){++++}-{4:4}, at:oom_reap_task_mmmm/oom_kill.c:566[inline]
#0:ffff8880335ed1b0(&mm->mmap_lock){++++}-{4:4}, at:oom_reap_taskmm/oom_kill.c:609[inline]
#0:ffff8880335ed1b0(&mm->mmap_lock){++++}-{4:4}, at:oom_reaper+0x2bb/0xc10mm/oom_kill.c:650
#1:ffffffff8e3066c0(mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at:mmu_notifier_invalidate_range_start_nonblockinclude/linux/mmu_notifier.h:495[inline] #1:ffffffff8e3066c0(mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at:zap_vma_for_reaping+0x193/0x380mm/memory.c:2119
#2:ffffffff8e306718(srcu){.+.+}-{0:0}, at:srcu_lock_acquireinclude/linux/srcu.h:187[inline]
#2:ffffffff8e306718(srcu){.+.+}-{0:0}, at:srcu_read_lockinclude/linux/srcu.h:294[inline]
#2:ffffffff8e306718(srcu){.+.+}-{0:0}, at:mn_hlist_invalidate_range_startmm/mmu_notifier.c:515[inline]
#2:ffffffff8e306718(srcu){.+.+}-{0:0}, at:__mmu_notifier_invalidate_range_start+0x5a1/0xb60mm/mmu_notifier.c:580
#3:ffff88803996caf8(&kvm->mn_invalidate_lock){+.+.}-{3:3}, at:spin_lockinclude/linux/spinlock_rt.h:45[inline]
#3:ffff88803996caf8(&kvm->mn_invalidate_lock){+.+.}-{3:3}, at:kvm_mmu_notifier_invalidate_range_start+0x1b7/0xc00virt/kvm/kvm_main.c:744CPU: 0 UID: 0 PID: 40 Comm: oom_reaper Not tainted syzkaller #0 PREEMPT_{RT,(full)} Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 __might_resched+0x329/0x480 kernel/sched/core.c:9163 __rt_spin_lock kernel/locking/spinlock_rt.c:48 [inline] rt_spin_lock+0xc2/0x400 kernel/locking/spinlock_rt.c:57 spin_lock include/linux/spinlock_rt.h:45 [inline] kvm_mmu_notifier_invalidate_range_start+0x1b7/0xc00 virt/kvm/kvm_main.c:744 mn_hlist_invalidate_range_start mm/mmu_notifier.c:525 [inline] __mmu_notifier_invalidate_range_start+0x6e4/0xb60 mm/mmu_notifier.c:580 mmu_notifier_invalidate_range_start_nonblock include/linux/mmu_notifier.h:498 [inline] zap_vma_for_reaping+0x1f7/0x380 mm/memory.c:2119 __oom_reap_task_mm mm/oom_kill.c:548 [inline] oom_reap_task_mm mm/oom_kill.c:585 [inline] oom_reap_task mm/oom_kill.c:609 [inline] oom_reaper+0x51e/0xc10 mm/oom_kill.c:650 kthread+0x388/0x470 kernel/kthread.c:436 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK> BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
in_atomic(): 0,irqs_disabled(): 0,non_block: 1, pid: 40, name:oom_reaperpreempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
4 locks held by oom_reaper/40:
#0:ffff8880335ed1b0(&mm->mmap_lock){++++}-{4:4}, at:mmap_read_trylockinclude/linux/mmap_lock.h:611[inline]
#0:ffff8880335ed1b0(&mm->mmap_lock){++++}-{4:4}, at:oom_reap_task_mmmm/oom_kill.c:566[inline]
#0:ffff8880335ed1b0(&mm->mmap_lock){++++}-{4:4}, at:oom_reap_taskmm/oom_kill.c:609[inline]
#0:ffff8880335ed1b0(&mm->mmap_lock){++++}-{4:4}, at:oom_reaper+0x2bb/0xc10mm/oom_kill.c:650
#1:ffffffff8e3066c0(mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at:__mmu_notifier_invalidate_range_end+0x67/0x400mm/mmu_notifier.c:611#2:ffffffff8e306718(srcu){.+.+}-{0:0}, at:__mmu_notifier_invalidate_range_end+0x67/0x400mm/mmu_notifier.c:611
#3:ffff88803996caf8(&kvm->mn_invalidate_lock){+.+.}-{3:3}, at:spin_lockinclude/linux/spinlock_rt.h:45[inline]
#3:ffff88803996caf8(&kvm->mn_invalidate_lock){+.+.}-{3:3}, at:kvm_mmu_notifier_invalidate_range_end+0x1d6/0x3d0virt/kvm/kvm_main.c:814CPU: 0 UID: 0 PID: 40 Comm: oom_reaper Tainted: G W syzkaller #0 PREEMPT_{RT,(full)} Tainted: [W]=WARN Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 __might_resched+0x329/0x480 kernel/sched/core.c:9163 __rt_spin_lock kernel/locking/spinlock_rt.c:48 [inline] rt_spin_lock+0xc2/0x400 kernel/locking/spinlock_rt.c:57 spin_lock include/linux/spinlock_rt.h:45 [inline] kvm_mmu_notifier_invalidate_range_end+0x1d6/0x3d0 virt/kvm/kvm_main.c:814 mn_hlist_invalidate_end mm/mmu_notifier.c:597 [inline] __mmu_notifier_invalidate_range_end+0x23b/0x400 mm/mmu_notifier.c:616 mmu_notifier_invalidate_range_end include/linux/mmu_notifier.h:511 [inline] zap_vma_for_reaping+0x2d9/0x380 mm/memory.c:2124 __oom_reap_task_mm mm/oom_kill.c:548 [inline] oom_reap_task_mm mm/oom_kill.c:585 [inline] oom_reap_task mm/oom_kill.c:609 [inline] oom_reaper+0x51e/0xc10 mm/oom_kill.c:650 kthread+0x388/0x470 kernel/kthread.c:436 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK>
oom_reaper: reaped process 6034 (syz.0.24), now anon-rss:0kB, file-rss:64kB, shmem-rss:0kB---
If you want syzbot to run the reproducer, reply with:
#syz test:git://repo/address.gitbranch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
syzbot
syzbotForwarded: Re: [syzbot] [mm?] BUG: sleeping function called from invalid context in kvm_mmu_notifier_invalidate_range_start
In reply to syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [mm?] BUG: sleeping function called from invalid context in kvm_mmu_notifier_invalidate_range_start
Author: [email protected]
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
Commit 312364f3534cc ("kernel.h: Add non_block_start/end()") added non_block_star()/end(). The intention was to catch any callbacks which depend on locks or sleep able conditionals in order to ensure forward progress. According to the commit message spinlocks were excluded "because spinlocks can't have an indirect dependency upon the page allocator…".
On PREEMPT_RT this leads to a splat because spinlock_t and rwlock_t are turned into a sleeping spinlock which have a might_sleep() as they could schedule() on lock contention.
Besids mm, the other used of non_block_start() is pwm. Here the hrtimer can acnqure a spinlock_t on RT and I can't tell other user but I assume it is not atomic on RT since it wouldn't be able to acquire its own (spinlock_t) lock.
Since spinlock_t (and rwlock_t) are not problem, add a sleeping_lock argument to __might_resched() signaling if this is scheduling request is from a sleeping lock (true) or regular scheduling request (false). Add the `true' argument to rtlock_might_resched() which is used on PREEMPT_RT for both sleeping lock types.
--- include/linux/kernel.h | 5 +++-- include/linux/sched.h | 24 ++++++++++++------------ kernel/locking/spinlock_rt.c | 2 +- kernel/sched/core.c | 7 ++++--- 4 files changed, 20 insertions(+), 18 deletions(-)
include/linux/kernel.h +3 -2
@@ -70,7 +70,8 @@ extern int dynamic_might_resched(void);#endif /* CONFIG_PREEMPT_* */ #ifdef CONFIG_DEBUG_ATOMIC_SLEEP -extern void __might_resched (const char *file,int line,unsigned int offsets); +extern void __might_resched (const char *file,int line,unsigned int offsets, +bool rt_sleeping_lock);extern void __might_sleep (const char *file,int line);extern void __cant_sleep (const char *file,int line,int preempt_offset);extern void __cant_migrate (const char *file,int line);
@@ -128,7 +129,7 @@ extern void __cant_migrate(const char *file, int line);# define non_block_end () WARN_ON(current->non_block_count-- == 0)#else static inline void __might_resched (const char *file,int line, -unsigned int offsets) { } +unsigned int offsets,bool rt_sleeping_lock) { }static inline void __might_sleep (const char *file,int line) { }# define might_sleep () do { might_resched(); } while (0)# define cant_sleep () do { } while (0)
include/linux/sched.h +12 -12
@@ -2158,9 +2158,9 @@ static inline int _cond_resched(void)#endif /* !CONFIG_PREEMPTION || CONFIG_PREEMPT_DYNAMIC */ -#define cond_resched () ({ \ - __might_resched(__FILE__, __LINE__, 0); \ - _cond_resched(); \ +#define cond_resched () ({ \ + __might_resched(__FILE__, __LINE__, 0, false); \ + _cond_resched(); \ }) extern int __cond_resched_lock(spinlock_t *lock) __must_hold(lock);
@@ -2186,19 +2186,19 @@ extern int __cond_resched_rwlock_write(rwlock_t *lock) __must_hold(lock); (PREEMPT_LOCK_OFFSET + (1U << MIGHT_RESCHED_RCU_SHIFT))#endif -#define cond_resched_lock (lock) ({ \ - __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS); \ - __cond_resched_lock(lock); \ +#define cond_resched_lock (lock) ({ \ + __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS, false); \ + __cond_resched_lock(lock); \ }) -#define cond_resched_rwlock_read (lock) ({ \ - __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS); \ - __cond_resched_rwlock_read(lock); \ +#define cond_resched_rwlock_read (lock) ({ \ + __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS, false); \ + __cond_resched_rwlock_read(lock); \ }) -#define cond_resched_rwlock_write (lock) ({ \ - __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS); \ - __cond_resched_rwlock_write(lock); \ +#define cond_resched_rwlock_write (lock) ({ \ + __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS, false); \ + __cond_resched_rwlock_write(lock); \ })#ifndef CONFIG_PREEMPT_RT
kernel/locking/spinlock_rt.c +1 -1
@@ -33,7 +33,7 @@ (rcu_preempt_depth() << MIGHT_RESCHED_RCU_SHIFT)#define rtlock_might_resched () \ - __might_resched(__FILE__, __LINE__, RTLOCK_RESCHED_OFFSETS) + __might_resched(__FILE__, __LINE__, RTLOCK_RESCHED_OFFSETS, true) static __always_inline void rtlock_lock(struct rt_mutex_base *rtm) {
kernel/sched/core.c +4 -3
@@ -9123,7 +9123,7 @@ void __might_sleep(const char *file, int line) (void *)current->task_state_change, (void *)current->task_state_change); -__might_resched (file, line,0 ); +__might_resched (file, line,0 , false); }EXPORT_SYMBOL (__might_sleep);
@@ -9148,7 +9148,8 @@ static inline bool resched_offsets_ok(unsigned int offsets)return nested == offsets; } -void __might_resched (const char *file,int line,unsigned int offsets) +void __might_resched (const char *file,int line,unsigned int offsets, +bool rt_sleeping_lock) {/* Ratelimiting timestamp: */ static unsigned long prev_jiffy;
@@ -9159,7 +9160,7 @@ void __might_resched(const char *file, int line, unsigned int offsets)rcu_sleep_check ();if ((resched_offsets_ok (offsets) && !irqs_disabled () && - !is_idle_task (current) && !current->non_block_count) || + !is_idle_task (current) && (rt_sleeping_lock || !current->non_block_count)) || system_state ==SYSTEM_BOOTING || system_state >SYSTEM_RUNNING || oops_in_progress)return ;
Signature · 1 line
2.55.0
syzbot
syzbotForwarded: Re: [syzbot] [kernel?] BUG: sleeping function called from invalid context in kvm_mmu_notifier_invalidate_range_start
In reply to syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] BUG: sleeping function called from invalid context in kvm_mmu_notifier_invalidate_range_start
Author: [email protected]
#syz test: https://git.infradead.org/users/dwmw2/linux.git seb-nonblock-rt-test
syzbot
syzbotsyzbot has found a reproducer for the following issue on:
syzbot has found a reproducer for the following issue on:
HEAD commit: 9b87fdc9af2f Merge tag 'sched_ext-for-7.3-rc3-fixes' of gi.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=16f46bf9580000 kernel config: https://syzkaller.appspot.com/x/.config?x=b454dc6b1b7acd30 dashboard link: https://syzkaller.appspot.com/bug?extid=c3178b6b512446632bac compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12f23925580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16f23925580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d9d20c79bd3c/disk-9b87fdc9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2a6a8f176798/vmlinux-9b87fdc9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/db8864d1c812/bzImage-9b87fdc9.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
in_atomic(): 0, irqs_disabled(): 0, non_block: 1, pid: 38, name: oom_reaperpreempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
locks held by oom_reaper/38: 4, last CPU#1:
#0: ffff8880370147b0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_trylock include/linux/mmap_lock.h:619 [inline]
#0: ffff8880370147b0 (&mm->mmap_lock){++++}-{4:4}, at: oom_reap_task_mm mm/oom_kill.c:566 [inline]
#0: ffff8880370147b0 (&mm->mmap_lock){++++}-{4:4}, at: oom_reap_task mm/oom_kill.c:609 [inline]
#0: ffff8880370147b0 (&mm->mmap_lock){++++}-{4:4}, at: oom_reaper+0x2b4/0xc10 mm/oom_kill.c:650
#1: ffffffff8e30af80 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at: mmu_notifier_invalidate_range_start_nonblock include/linux/mmu_notifier.h:495 [inline] #1: ffffffff8e30af80 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at: zap_vma_for_reaping+0x193/0x380 mm/memory.c:2266
#2: ffffffff8e30afd8 (srcu){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:198 [inline]
#2: ffffffff8e30afd8 (srcu){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:305 [inline]
#2: ffffffff8e30afd8 (srcu){.+.+}-{0:0}, at: mn_hlist_invalidate_range_start mm/mmu_notifier.c:515 [inline]
#2: ffffffff8e30afd8 (srcu){.+.+}-{0:0}, at: __mmu_notifier_invalidate_range_start+0x5c6/0xb80 mm/mmu_notifier.c:580
#3: ffff8880465ad560 (&kvm->mn_invalidate_lock){+.+.}-{3:3}, at: spin_lock include/linux/spinlock_rt.h:45 [inline]
#3: ffff8880465ad560 (&kvm->mn_invalidate_lock){+.+.}-{3:3}, at: kvm_mmu_notifier_invalidate_range_start+0x1b6/0xc10 virt/kvm/kvm_main.c:745
CPU: 1 UID: 0 PID: 38 Comm: oom_reaper Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
__might_resched+0x31b/0x470 kernel/sched/core.c:9257
__rt_spin_lock kernel/locking/spinlock_rt.c:48 [inline]
rt_spin_lock+0xc2/0x400 kernel/locking/spinlock_rt.c:57
spin_lock include/linux/spinlock_rt.h:45 [inline]
kvm_mmu_notifier_invalidate_range_start+0x1b6/0xc10 virt/kvm/kvm_main.c:745
mn_hlist_invalidate_range_start mm/mmu_notifier.c:525 [inline]
__mmu_notifier_invalidate_range_start+0x709/0xb80 mm/mmu_notifier.c:580
mmu_notifier_invalidate_range_start_nonblock include/linux/mmu_notifier.h:498 [inline]
zap_vma_for_reaping+0x1f7/0x380 mm/memory.c:2266
__oom_reap_task_mm mm/oom_kill.c:548 [inline]
oom_reap_task_mm mm/oom_kill.c:585 [inline]
oom_reap_task mm/oom_kill.c:609 [inline]
oom_reaper+0x519/0xc10 mm/oom_kill.c:650
kthread+0x38b/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>oom_reaper: reaped process 8617 (syz.2.1028), now anon-rss:0kB, file-rss:72kB, shmem-rss:0kB
---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
Lorenzo Stoakes (ARM)
Acked-by David Woodhouse+cc Sebastian
Quoted 36 lines · syzbot
syzbot has found a reproducer for the following issue on:
HEAD commit: 9b87fdc9af2f Merge tag 'sched_ext-for-7.3-rc3-fixes' of gi.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=16f46bf9580000 kernel config: https://syzkaller.appspot.com/x/.config?x=b454dc6b1b7acd30 dashboard link: https://syzkaller.appspot.com/bug?extid=c3178b6b512446632bac compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12f23925580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16f23925580000Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d9d20c79bd3c/disk-9b87fdc9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2a6a8f176798/vmlinux-9b87fdc9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/db8864d1c812/bzImage-9b87fdc9.xzIMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by [email protected]BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
in_atomic(): 0,irqs_disabled(): 0,non_block: 1, pid: 38, name:oom_reaperpreempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
locks held by oom_reaper/38: 4, last CPU#1:
#0:ffff8880370147b0(&mm->mmap_lock){++++}-{4:4}, at:mmap_read_trylockinclude/linux/mmap_lock.h:619[inline]
#0:ffff8880370147b0(&mm->mmap_lock){++++}-{4:4}, at:oom_reap_task_mmmm/oom_kill.c:566[inline]
#0:ffff8880370147b0(&mm->mmap_lock){++++}-{4:4}, at:oom_reap_taskmm/oom_kill.c:609[inline]
#0:ffff8880370147b0(&mm->mmap_lock){++++}-{4:4}, at:oom_reaper+0x2b4/0xc10mm/oom_kill.c:650
#1:ffffffff8e30af80(mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at:mmu_notifier_invalidate_range_start_nonblockinclude/linux/mmu_notifier.h:495[inline] #1:ffffffff8e30af80(mmu_notifier_invalidate_range_start){+.+.}-{0:0}, at:zap_vma_for_reaping+0x193/0x380mm/memory.c:2266
#2:ffffffff8e30afd8(srcu){.+.+}-{0:0}, at:srcu_lock_acquireinclude/linux/srcu.h:198[inline]
#2:ffffffff8e30afd8(srcu){.+.+}-{0:0}, at:srcu_read_lockinclude/linux/srcu.h:305[inline]
#2:ffffffff8e30afd8(srcu){.+.+}-{0:0}, at:mn_hlist_invalidate_range_startmm/mmu_notifier.c:515[inline]
#2:ffffffff8e30afd8(srcu){.+.+}-{0:0}, at:__mmu_notifier_invalidate_range_start+0x5c6/0xb80mm/mmu_notifier.c:580
#3:ffff8880465ad560(&kvm->mn_invalidate_lock){+.+.}-{3:3}, at:spin_lockinclude/linux/spinlock_rt.h:45[inline]
#3:ffff8880465ad560(&kvm->mn_invalidate_lock){+.+.}-{3:3}, at:kvm_mmu_notifier_invalidate_range_start+0x1b6/0xc10virt/kvm/kvm_main.c:745
Quoted 7 lines
CPU: 1 UID: 0 PID: 38 Comm: oom_reaper Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
__might_resched+0x31b/0x470 kernel/sched/core.c:9257
__rt_spin_lock kernel/locking/spinlock_rt.c:48 [inline]Seems like a false positive and an RT thing?
Seems like [0] addresses it?
[0]:https://lore.kernel.org/all/[email protected]/
Quoted 15 lines
rt_spin_lock+0xc2/0x400 kernel/locking/spinlock_rt.c:57 spin_lock include/linux/spinlock_rt.h:45 [inline] kvm_mmu_notifier_invalidate_range_start+0x1b6/0xc10 virt/kvm/kvm_main.c:745 mn_hlist_invalidate_range_start mm/mmu_notifier.c:525 [inline] __mmu_notifier_invalidate_range_start+0x709/0xb80 mm/mmu_notifier.c:580 mmu_notifier_invalidate_range_start_nonblock include/linux/mmu_notifier.h:498 [inline] zap_vma_for_reaping+0x1f7/0x380 mm/memory.c:2266 __oom_reap_task_mm mm/oom_kill.c:548 [inline] oom_reap_task_mm mm/oom_kill.c:585 [inline] oom_reap_task mm/oom_kill.c:609 [inline] oom_reaper+0x519/0xc10 mm/oom_kill.c:650 kthread+0x38b/0x470 kernel/kthread.c:436 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK>
Quoted 7 lines
oom_reaper: reaped process 8617 (syz.2.1028), now anon-rss:0kB, file-rss:72kB, shmem-rss:0kB---
If you want syzbot to run the reproducer, reply with:
#syz test:git://repo/address.gitbranch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
OK I attach the patch, so:
#syz test
--
Cheers, Lorenzo
From mboxrd@z Thu Jan 1 00:00:00 1970
Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BB2344A41A for <[email protected]>; Wed, 16 Sep 2026 15:51:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789573873; cv=none; b=dJPmBKlAMPVABCbPBWpBKZodIllr2d2QNabhtLlFDz9lyXv/N12uXWbjtq3jJIYMlBIAN5Z7cs0uUJ8LGHmMdIjaltl56jWI5NqOhDn+VcWYZloQ31yoTF36RedNsUiuy97JDp/7igkqMGqsKTllVFayZREXuia2WGMOSAWx0HM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789573873; c=relaxed/simple; bh=bMIC0/VgzxgcdJMTvr5DMj9RkHg2F9CQ0MIQ8poAnTc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UYjMfx04slUnRGBKyXryU+P462Rs3cPXRb5QqoKPyu9kUrATC+2IWh1IFPZBC2Rv6u+YG2bvaQMRhRtBfnpJWlhkkDEC8nDK8iln61SLtRkeHej9NtLMwG1Uv2P7g+yswVJntt7HCdVbi+lKUu5Kjf5fLRK+/umqAF16x+vNkLg=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de [email protected] header.b=eXmX5pZ3; dkim=permerror (0-bit key) header.d=linutronix.de [email protected] header.b=GoMKDz3z; arc=none smtp.client-ip=193.142.43.55
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=linutronix.de [email protected] header.b="eXmX5pZ3"; dkim=permerror (0-bit key) header.d=linutronix.de [email protected] header.b="GoMKDz3z" Date: Wed, 16 Sep 2026 17:51:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1789573867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mV6UhFNULl/p2epmPanGCrS/5V06dPEqYq9UbXTjiR4=; b=eXmX5pZ3fxsJjqAcv+mJwxaldl1ueJr7KBhn0U7kSJ6wguIT6E/SZijiQ+5NT1cas9lmgD Oy7bRbCq+/fn6eNMD4xxQLgjCnGdYPNeTz529w1VMabqxjRnWfZRJCTX4rVbYY4YNwQhsG hfmHeyfr3xeaD5onr47Z3NsKkP/aw5P28PIcHWfSfzxU8k0pNNSe81jgDhE9EM1oV3plS7 6d51tQzxjBxvEusoe7BudTXoaPEHzcR62IkhzGHpo9NQMeqecIzVm1xX7gSIEyTO5c2sn7 mpWeKzCFD+p9SeL9rs/3Y8kNDQRmvkERlUlHs8YASOuMPp2N0MVoQLt1Yv5dZw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1789573867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mV6UhFNULl/p2epmPanGCrS/5V06dPEqYq9UbXTjiR4=; b=GoMKDz3ze5L2J0XPU9UZ5pR8NoOfiSQXkcKaL0iX8wO8yl7OZtfRfyMhfvuJlIRQhW/aqm VSEwk4tF1BOyn9Ag==
From: Sebastian Andrzej Siewior <[email protected]>
To: [email protected], [email protected]
Cc: Ben Segall <[email protected]>, Boqun Feng <[email protected]>,
Clark Williams <[email protected]>,
David Woodhouse <[email protected]>,
Dietmar Eggemann <[email protected]>,
Ingo Molnar <[email protected]>, Juri Lelli <[email protected]>, K Prateek Nayak <[email protected]>,
Mel Gorman <[email protected]>, Michal Hocko <[email protected]>, Peter Zijlstra <[email protected]>, Sean Young <[email protected]>, Steven Rostedt <[email protected]>,
Thierry Reding <[email protected]>,
Valentin Schneider <[email protected]>,
Vincent Guittot <[email protected]>,
Waiman Long <[email protected]>, Will Deacon <[email protected]>
Subject: [PATCH v2] sched: Allow sleeping spinlocks on PREEMPT_RT within
non_block_start()/end block.
Message-ID: <[email protected]>
References: <[email protected]>
Precedence: bulk
X-Mailing-List: [email protected]
List-Id: <linux-rt-devel.lists.linux.dev>
List-Subscribe: <mailto:[email protected]>
List-Unsubscribe: <mailto:[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
In-Reply-To: <[email protected]>
Commit 312364f3534cc ("kernel.h: Add non_block_start/end()") added non_block_star()/end(). The intention was to catch any callbacks which depend on locks or sleep able conditionals in order to ensure forward progress. According to the commit message spinlocks were excluded "because spinlocks can't have an indirect dependency upon the page allocator=E2=80=A6".
On PREEMPT_RT this leads to a splat because spinlock_t and rwlock_t are turned into a sleeping spinlock which have a might_sleep() as they could schedule() on lock contention.
Besids mm, the other used of non_block_start() is pwm. Here the hrtimer can acnqure a spinlock_t on RT and I can't tell other user but I assume it is not atomic on RT since it wouldn't be able to acquire its own (spinlock_t) lock.
Since spinlock_t (and rwlock_t) are not problem, add a sleeping_lock argument to __might_resched() signaling if this is scheduling request is from a sleeping lock (true) or regular scheduling request (false). Add the `true' argument to rtlock_might_resched() which is used on PREEMPT_RT for both sleeping lock types.
---
v1=E2=80=A6v2: https://lore.kernel.org/all/20260821095755.am1-Segb@linutron=
ix.de/
- repost with collected tags
- Add Reported-by for syzbot
include/linux/kernel.h | 5 +++-- include/linux/sched.h | 24 ++++++++++++------------ kernel/locking/spinlock_rt.c | 2 +- kernel/sched/core.c | 7 ++++--- 4 files changed, 20 insertions(+), 18 deletions(-)
include/linux/kernel.h +0 -0
@@ -70,7 +70,8 @@ extern int dynamic_might_resched(void);#endif /* CONFIG_PREEMPT_* */
=20
#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
-extern void __might_resched(const char *file, int line, unsigned int offse= ts);
+extern void __might_resched(const char *file, int line, unsigned int offse= ts,
+ bool rt_sleeping_lock);
extern void __might_sleep(const char *file, int line);
extern void __cant_sleep(const char *file, int line);
extern void __cant_migrate(const char *file, int line);
@@ -128,7 +129,7 @@ extern void __cant_migrate(const char *file, int line);
# define non_block_end() WARN_ON(current->non_block_count-- =3D=3D 0)
#else
static inline void __might_resched(const char *file, int line,
- unsigned int offsets) { }
+ unsigned int offsets, bool rt_sleeping_lock) { }
static inline void __might_sleep(const char *file, int line) { }
# define might_sleep() do { might_resched(); } while (0)
# define cant_sleep() do { } while (0)include/linux/sched.h +0 -0
@@ -2173,9 +2173,9 @@ static inline int _cond_resched(void)
=20
#endif /* !CONFIG_PREEMPTION || CONFIG_PREEMPT_DYNAMIC */
=20
-#define cond_resched() ({ \
- __might_resched(__FILE__, __LINE__, 0); \
- _cond_resched(); \
+#define cond_resched() ({ \
+ __might_resched(__FILE__, __LINE__, 0, false); \
+ _cond_resched(); \
})
=20
extern int __cond_resched_lock(spinlock_t *lock) __must_hold(lock);
@@ -2201,19 +2201,19 @@ extern int __cond_resched_rwlock_write(rwlock_t *lo= ck) __must_hold(lock);
(PREEMPT_LOCK_OFFSET + (1U << MIGHT_RESCHED_RCU_SHIFT))
#endif
=20
-#define cond_resched_lock(lock) ({ \
- __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS); \
- __cond_resched_lock(lock); \
+#define cond_resched_lock(lock) ({ \
+ __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS, false);=
\
+ __cond_resched_lock(lock); \
})
=20
-#define cond_resched_rwlock_read(lock) ({ \
- __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS); \
- __cond_resched_rwlock_read(lock); \
+#define cond_resched_rwlock_read(lock) ({ \
+ __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS, false);=
\
+ __cond_resched_rwlock_read(lock); \
})
=20
-#define cond_resched_rwlock_write(lock) ({ \
- __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS); \
- __cond_resched_rwlock_write(lock); \
+#define cond_resched_rwlock_write(lock) ({ \
+ __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS, false);=
\
+ __cond_resched_rwlock_write(lock); \
})
=20
#ifndef CONFIG_PREEMPT_RT
kernel/locking/spinlock_rt.c +0 -0
@@ -33,7 +33,7 @@ (rcu_preempt_depth () <<MIGHT_RESCHED_RCU_SHIFT )
=20
#define rtlock_might_resched() \
- __might_resched(__FILE__, __LINE__, RTLOCK_RESCHED_OFFSETS)
+ __might_resched(__FILE__, __LINE__, RTLOCK_RESCHED_OFFSETS, true)
=20
static __always_inline void rtlock_lock(struct rt_mutex_base *rtm) {
kernel/sched/core.c +0 -0
@@ -9183,7 +9183,7 @@ void __might_sleep(const char *file, int line) (void *)current->task_state_change, (void *)current->task_state_change);
=20
- __might_resched(file, line, 0);
+ __might_resched(file, line, 0, false);
}
EXPORT_SYMBOL(__might_sleep);
=20
@@ -9208,7 +9208,8 @@ static inline bool resched_offsets_ok(unsigned int of= fsets)
return nested =3D=3D offsets;
}
=20
-void __might_resched(const char *file, int line, unsigned int offsets) +void __might_resched(const char *file, int line, unsigned int offsets,
+ bool rt_sleeping_lock)
{
/* Ratelimiting timestamp: */
static unsigned long prev_jiffy;
@@ -9219,7 +9220,7 @@ void __might_resched(const char *file, int line, unsi= gned int offsets)
rcu_sleep_check();
=20
if ((resched_offsets_ok(offsets) && !irqs_disabled() &&
- !is_idle_task(current) && !current->non_block_count) || + !is_idle_task(current) && (rt_sleeping_lock || !current->non_block_c= ount)) ||
system_state =3D=3D SYSTEM_BOOTING || system_state > SYSTEM_RUNNING || oops_in_progress)
return;
--=20
2.55.0
syzbot
syzbotsyzbot tried to test the proposed patch but the build/boot failed:
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
failed to apply patch:
error: corrupt patch at line 7
Tested on:
commit: 9b87fdc9 Merge tag 'sched_ext-for-7.3-rc3-fixes' of gi.. git tree: upstream kernel config: https://syzkaller.appspot.com/x/.config?x=b454dc6b1b7acd30 dashboard link: https://syzkaller.appspot.com/bug?extid=c3178b6b512446632bac
compiler:
patch: https://syzkaller.appspot.com/x/patch.diff?x=15a16bf9580000
Sebastian Andrzej Siewior
maintainerQuoted 3 lines · Lorenzo Stoakes (ARM)
Quoted 1 line
dashboard link: https://syzkaller.appspot.com/bug?extid=c3178b6b512446632bac
Seems like a false positive and an RT thing?
yes, it does. The proposed patch has a matching reported-by of the report. dwmw2 did test it via his tree
https://lore.kernel.org/all/[email protected]/
Sebastian
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 3 lines · Lorenzo Stoakes (ARM)
Quoted 1 line
dashboard link: https://syzkaller.appspot.com/bug?extid=c3178b6b512446632bac
Seems like a false positive and an RT thing?
yes, it does. The proposed patch has a matching reported-by of the report. dwmw2 did test it via his tree
https://lore.kernel.org/all/[email protected]/
Thanks! I may try that here then as my attempt at a test failed, but I think v. v. likely this is what it is.
Quoted 2 lines
Sebastian
--
Cheers, Lorenzo
Quoted 6 lines · syzbot
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
failed to apply patch:
error: corrupt patch at line 7
OK let's try again, aping
https://lore.kernel.org/all/[email protected]/
as I see this branch is still there (David W - I hope this is OK! :)
#syz test git://git.infradead.org/users/dwmw2/linux.git seb-nonblock-rt-test
Quoted 12 lines
Tested on:
commit: 9b87fdc9 Merge tag 'sched_ext-for-7.3-rc3-fixes' of gi.. git tree: upstream kernel config: https://syzkaller.appspot.com/x/.config?x=b454dc6b1b7acd30 dashboard link: https://syzkaller.appspot.com/bug?extid=c3178b6b512446632baccompiler:
patch: https://syzkaller.appspot.com/x/patch.diff?x=15a16bf9580000
--
Cheers, Lorenzo
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Tested on:
commit: f902e69c sched: Allow sleeping spinlocks on PREEMPT_RT.. git tree: git://git.infradead.org/users/dwmw2/linux.git seb-nonblock-rt-test console output: https://syzkaller.appspot.com/x/log.txt?x=17d63bf9580000 kernel config: https://syzkaller.appspot.com/x/.config?x=8a263b38e64491d5 dashboard link: https://syzkaller.appspot.com/bug?extid=c3178b6b512446632bac compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.