From: "tip-bot2 for Niels Pressel" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Niels Pressel <npressel@ethz.ch>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: core/urgent] entry/rseq: Fix hard lockup on granted time slice extension
Date: Thu, 06 Aug 2026 12:48:05 -0000 [thread overview]
Message-ID: <178602048581.708.11608729612787939146.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260806113429.38333-1-npressel@ethz.ch>
The following commit has been merged into the core/urgent branch of tip:
Commit-ID: f81845889e128d2e5f8f2f38eb7339cc74640f4f
Gitweb: https://git.kernel.org/tip/f81845889e128d2e5f8f2f38eb7339cc74640f4f
Author: Niels Pressel <npressel@ethz.ch>
AuthorDate: Thu, 06 Aug 2026 13:34:29 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 06 Aug 2026 14:42:22 +02:00
entry/rseq: Fix hard lockup on granted time slice extension
In __exit_to_user_mode_loop(), TSE eligibility is checked while
IRQs are enabled. Granting a TSE might involve rearming the
hrtimers. However, hrtimer_rearm_deferred_tif() is expected to be
called with IRQs disabled (see include/linux/hrtimer_rearm.h:17).
Calling the function with IRQs enabled can lead to a hard lockup
because __hrtimer_rearm_deferred() acquires a raw spinlock (without
disabling IRQs) that is also acquired in hard IRQ context within
hrtimer_run_queues().
Lockdep flags the issue when running the rseq selftests on the
7.2-rc5 release:
WARNING: ./include/linux/hrtimer_rearm.h:17 at irqentry_exit, CPU#1: slice_test
Originally, the issue was discovered because of intermittent lockups
when heavily using rseq TSEs.
Following the suggestion from Peter Zijlstra, fix this potential lockup
by reflowing __exit_to_user_mode_loop() to only enable IRQs after the
TSE check.
Fixes: 15dd3a948855 ("hrtimer: Push reprogramming timers into the interrupt return path")
Signed-off-by: Niels Pressel <npressel@ethz.ch>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260806113429.38333-1-npressel@ethz.ch
---
include/linux/rseq_entry.h | 8 ++++----
kernel/entry/common.c | 10 +++++-----
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/linux/rseq_entry.h b/include/linux/rseq_entry.h
index ed9da6e..772e72d 100644
--- a/include/linux/rseq_entry.h
+++ b/include/linux/rseq_entry.h
@@ -132,6 +132,8 @@ static __always_inline bool __rseq_grant_slice_extension(bool work_pending)
union rseq_slice_state state;
struct rseq __user *rseq;
+ lockdep_assert_irqs_disabled();
+
if (!rseq_slice_extension_enabled())
return false;
@@ -219,10 +221,8 @@ static __always_inline bool __rseq_grant_slice_extension(bool work_pending)
*
* which would be inconsistent state.
*/
- scoped_guard(irq) {
- clear_tsk_need_resched(curr);
- clear_preempt_need_resched();
- }
+ clear_tsk_need_resched(curr);
+ clear_preempt_need_resched();
return true;
efault:
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index e3d381f..e7dae46 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -47,13 +47,13 @@ static __always_inline unsigned long __exit_to_user_mode_loop(struct pt_regs *re
* items have been completed.
*/
while (ti_work & EXIT_TO_USER_MODE_WORK_LOOP) {
-
+ /* Check rseq slice extensions with IRQs disabled */
+ bool sched = (ti_work & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)) &&
+ !rseq_grant_slice_extension(ti_work, TIF_SLICE_EXT_DENY);
local_irq_enable();
- if (ti_work & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)) {
- if (!rseq_grant_slice_extension(ti_work, TIF_SLICE_EXT_DENY))
- schedule();
- }
+ if (sched)
+ schedule();
if (ti_work & _TIF_UPROBE)
uprobe_notify_resume(regs);
next prev parent reply other threads:[~2026-08-06 12:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 11:34 [PATCH v2] rseq: fix " Niels Pressel
2026-08-06 12:48 ` tip-bot2 for Niels Pressel [this message]
2026-08-07 21:15 ` [tip: core/urgent] entry/rseq: Fix " Thomas Gleixner
2026-08-08 8:36 ` Peter Zijlstra
2026-08-08 11:23 ` Thomas Gleixner
2026-08-09 7:29 ` Niels Pressel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178602048581.708.11608729612787939146.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=npressel@ethz.ch \
--cc=peterz@infradead.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®