]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rseq: Simplify registration
authorThomas Gleixner <tglx@linutronix.de>
Mon, 27 Oct 2025 08:44:24 +0000 (09:44 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 4 Nov 2025 07:30:05 +0000 (08:30 +0100)
There is no point to read the critical section element in the newly
registered user space RSEQ struct first in order to clear it.

Just clear it and be done with it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://patch.msgid.link/20251027084306.274661227@linutronix.de
kernel/rseq.c

index 51fafc4528b0f734e57468939983e2f290ed057f..80af48a972f0623842f1007c6cb833715797a543 100644 (file)
@@ -492,11 +492,9 @@ void rseq_syscall(struct pt_regs *regs)
 /*
  * sys_rseq - setup restartable sequences for caller thread.
  */
-SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len,
-               int, flags, u32, sig)
+SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, int, flags, u32, sig)
 {
        int ret;
-       u64 rseq_cs;
 
        if (flags & RSEQ_FLAG_UNREGISTER) {
                if (flags & ~RSEQ_FLAG_UNREGISTER)
@@ -557,11 +555,9 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len,
         * avoid a potential segfault on return to user-space. The proper thing
         * to do would have been to fail the registration but this would break
         * older libcs that reuse the rseq area for new threads without
-        * clearing the fields.
+        * clearing the fields. Don't bother reading it, just reset it.
         */
-       if (rseq_get_rseq_cs_ptr_val(rseq, &rseq_cs))
-               return -EFAULT;
-       if (rseq_cs && clear_rseq_cs(rseq))
+       if (put_user(0UL, &rseq->rseq_cs))
                return -EFAULT;
 
 #ifdef CONFIG_DEBUG_RSEQ