[tip: core/urgent] rseq: Prevent hard lockup on granted time slice extension

From: tip-bot2 for Niels Pressel

Date: Mon Aug 10 2026 - 03:42:31 EST


The following commit has been merged into the core/urgent branch of tip:

Commit-ID: ada54c2ba652348c590d1ace6a2f4ff77cbbf809
Gitweb: https://git.kernel.org/tip/ada54c2ba652348c590d1ace6a2f4ff77cbbf809
Author: Niels Pressel <npressel@xxxxxxx>
AuthorDate: Sun, 02 Aug 2026 14:44:23 +02:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Mon, 10 Aug 2026 09:37:54 +02:00

rseq: Prevent hard lockup on granted time slice extension

__exit_to_user_mode_loop() invokes rseq_grant_timeslice_extension() with
interrupts enabled. If the extension is granted it invokes
hrtimer_rearm_deferred_tif() to ensure that a pending deferred hrtimer
rearm is handled before exiting to user space.

Though this invokes __hrtimer_rearm_deferred() which expects to be invoked
with interrupts disabled as it takes hrtimer_cpu_base::lock with
raw_spin_lock(). That's a livelock waiting to happen and caught by lockdep:

WARNING: ./include/linux/hrtimer_rearm.h:17 at irqentry_exit, CPU#1: slice_test
WARNING: inconsistent lock state
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.

Prevent this by disabling interrupts around the invocation of
hrtimer_rearm_deferred_tif() in rseq_grant_timeslice_extension().

[ tglx: Massaged change log ]

Fixes: 15dd3a948855 ("hrtimer: Push reprogramming timers into the interrupt return path")
Signed-off-by: Niels Pressel <npressel@xxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Link: https://patch.msgid.link/20260802124423.51616-1-npressel@xxxxxxx
---
include/linux/rseq_entry.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/linux/rseq_entry.h b/include/linux/rseq_entry.h
index ed9da6e..31ce349 100644
--- a/include/linux/rseq_entry.h
+++ b/include/linux/rseq_entry.h
@@ -233,6 +233,7 @@ efault:
static __always_inline bool rseq_grant_slice_extension(unsigned long ti_work, unsigned long mask)
{
if (unlikely(__rseq_grant_slice_extension(ti_work & mask))) {
+ guard(irq)();
hrtimer_rearm_deferred_tif(ti_work);
return true;
}