]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rseq: Use static branch for syscall exit debug when GENERIC_IRQ_ENTRY=y
authorThomas Gleixner <tglx@linutronix.de>
Mon, 27 Oct 2025 08:45:05 +0000 (09:45 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 4 Nov 2025 07:33:27 +0000 (08:33 +0100)
Make the syscall exit debug mechanism available via the static branch on
architectures which utilize the generic entry code.

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/20251027084307.333440475@linutronix.de
include/linux/entry-common.h
include/linux/rseq_entry.h
kernel/rseq.c

index 75b194c34e18d41b3a95580694b6d5a140a74bd8..d967184ae08fc06c378d4f5463dfef1c87a9dcca 100644 (file)
@@ -146,7 +146,7 @@ static __always_inline void syscall_exit_to_user_mode_work(struct pt_regs *regs)
                        local_irq_enable();
        }
 
-       rseq_syscall(regs);
+       rseq_debug_syscall_return(regs);
 
        /*
         * Do one-time syscall specific work. If these work items are
index 5bdcf5b5f5958ce89c9f2406d6a00dd07db27530..fb53a6ff05d7f3980cf2f7b0bb9969e344fa03ce 100644 (file)
@@ -296,9 +296,18 @@ static __always_inline void rseq_exit_to_user_mode(void)
        ev->events = 0;
 }
 
+void __rseq_debug_syscall_return(struct pt_regs *regs);
+
+static inline void rseq_debug_syscall_return(struct pt_regs *regs)
+{
+       if (static_branch_unlikely(&rseq_debug_enabled))
+               __rseq_debug_syscall_return(regs);
+}
+
 #else /* CONFIG_RSEQ */
 static inline void rseq_note_user_irq_entry(void) { }
 static inline void rseq_exit_to_user_mode(void) { }
+static inline void rseq_debug_syscall_return(struct pt_regs *regs) { }
 #endif /* !CONFIG_RSEQ */
 
 #endif /* _LINUX_RSEQ_ENTRY_H */
index abd6bfadbcc66746f10dc5a6d66301fd30054b9b..97631554ae96252fdaf86b4dc28944b93caebf8b 100644 (file)
@@ -473,12 +473,11 @@ error:
        force_sigsegv(sig);
 }
 
-#ifdef CONFIG_DEBUG_RSEQ
 /*
  * Terminate the process if a syscall is issued within a restartable
  * sequence.
  */
-void rseq_syscall(struct pt_regs *regs)
+void __rseq_debug_syscall_return(struct pt_regs *regs)
 {
        struct task_struct *t = current;
        u64 csaddr;
@@ -496,6 +495,13 @@ void rseq_syscall(struct pt_regs *regs)
 fail:
        force_sig(SIGSEGV);
 }
+
+#ifdef CONFIG_DEBUG_RSEQ
+/* Kept around to keep GENERIC_ENTRY=n architectures supported. */
+void rseq_syscall(struct pt_regs *regs)
+{
+       __rseq_debug_syscall_return(regs);
+}
 #endif
 
 /*