]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rseq: Protect rseq_reset() against interrupts
authorThomas Gleixner <tglx@kernel.org>
Tue, 28 Apr 2026 08:14:41 +0000 (10:14 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 1 May 2026 19:32:20 +0000 (21:32 +0200)
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

index b9d62fc2140dd11d5850ad5ce6c2c932ccaad315..f446909551df05d4af52b366a459cfd00126f47d 100644 (file)
@@ -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;
 }