[tip: sched/urgent] rseq: Protect rseq_reset() against interrupts

tip-bot2 for Thomas Gleixner posted 1 patch 1 month, 1 week ago
include/linux/rseq.h | 2 ++
1 file changed, 2 insertions(+)
[tip: sched/urgent] rseq: Protect rseq_reset() against interrupts
Posted by tip-bot2 for Thomas Gleixner 1 month, 1 week ago
The following commit has been merged into the sched/urgent branch of tip:

Commit-ID:     e9766e6f7d330dce7530918d8c6e3ec96d6c6e24
Gitweb:        https://git.kernel.org/tip/e9766e6f7d330dce7530918d8c6e3ec96d6c6e24
Author:        Thomas Gleixner <tglx@kernel.org>
AuthorDate:    Tue, 28 Apr 2026 10:14:41 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 01 May 2026 21:32:20 +02:00

rseq: Protect rseq_reset() against interrupts

rseq_reset() uses memset() to clear the tasks rseq data. That's racy
against membarrier() and preemption.

Guard it with irqsave to cure this.

Fixes: faba9d250eae ("rseq: Introduce struct rseq_data")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Link: https://patch.msgid.link/20260428224427.353887714%40kernel.org
Cc: stable@vger.kernel.org
---
 include/linux/rseq.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/rseq.h b/include/linux/rseq.h
index b9d62fc..f446909 100644
--- a/include/linux/rseq.h
+++ b/include/linux/rseq.h
@@ -119,6 +119,8 @@ static inline void rseq_virt_userspace_exit(void)
 
 static inline void rseq_reset(struct task_struct *t)
 {
+	/* Protect against preemption and membarrier IPI */
+	guard(irqsave)();
 	memset(&t->rseq, 0, sizeof(t->rseq));
 	t->rseq.ids.cpu_id = RSEQ_CPU_ID_UNINITIALIZED;
 }