[GIT pull] core/rseq for v6.18-rc1

Thomas Gleixner posted 1 patch 2 days, 12 hours ago
include/linux/rseq.h                | 11 ++++++++---
kernel/rseq.c                       | 10 +++++-----
tools/testing/selftests/rseq/rseq.c |  8 ++++----
3 files changed, 17 insertions(+), 12 deletions(-)
[GIT pull] core/rseq for v6.18-rc1
Posted by Thomas Gleixner 2 days, 12 hours ago
Linus,

please pull the latest core/rseq branch from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-rseq-2025-09-29

up to:  a001cd248ab2: rseq/selftests: Use weak symbol reference, not definition, to link with glibc

Two fixes for RSEQ:

  1) Protect the event mask modification against the membarrier() IPI as
     otherwise the RmW operation is unprotected and events might be lost.

  2) Fix the weak symbol reference in rseq selftests

     The current weak RSEQ symbols definitions which were added to allow
     static linkage are not working correctly as the effectively re-define
     the glibc symbols leading to multiple versions of the symbols when
     compiled with -fno-common. Mark them as 'extern' to convert them from
     weak symbol definitions to weak symbol references. That works with
     static and dynamic linkage independent of -fcommon and -fno-common.

Thanks,

	tglx

------------------>
Sean Christopherson (1):
      rseq/selftests: Use weak symbol reference, not definition, to link with glibc

Thomas Gleixner (1):
      rseq: Protect event mask against membarrier IPI


 include/linux/rseq.h                | 11 ++++++++---
 kernel/rseq.c                       | 10 +++++-----
 tools/testing/selftests/rseq/rseq.c |  8 ++++----
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/include/linux/rseq.h b/include/linux/rseq.h
index bc8af3eb5598..1fbeb61babeb 100644
--- a/include/linux/rseq.h
+++ b/include/linux/rseq.h
@@ -7,6 +7,12 @@
 #include <linux/preempt.h>
 #include <linux/sched.h>
 
+#ifdef CONFIG_MEMBARRIER
+# define RSEQ_EVENT_GUARD	irq
+#else
+# define RSEQ_EVENT_GUARD	preempt
+#endif
+
 /*
  * Map the event mask on the user-space ABI enum rseq_cs_flags
  * for direct mask checks.
@@ -41,9 +47,8 @@ static inline void rseq_handle_notify_resume(struct ksignal *ksig,
 static inline void rseq_signal_deliver(struct ksignal *ksig,
 				       struct pt_regs *regs)
 {
-	preempt_disable();
-	__set_bit(RSEQ_EVENT_SIGNAL_BIT, &current->rseq_event_mask);
-	preempt_enable();
+	scoped_guard(RSEQ_EVENT_GUARD)
+		__set_bit(RSEQ_EVENT_SIGNAL_BIT, &current->rseq_event_mask);
 	rseq_handle_notify_resume(ksig, regs);
 }
 
diff --git a/kernel/rseq.c b/kernel/rseq.c
index b7a1ec327e81..2452b7366b00 100644
--- a/kernel/rseq.c
+++ b/kernel/rseq.c
@@ -342,12 +342,12 @@ static int rseq_need_restart(struct task_struct *t, u32 cs_flags)
 
 	/*
 	 * Load and clear event mask atomically with respect to
-	 * scheduler preemption.
+	 * scheduler preemption and membarrier IPIs.
 	 */
-	preempt_disable();
-	event_mask = t->rseq_event_mask;
-	t->rseq_event_mask = 0;
-	preempt_enable();
+	scoped_guard(RSEQ_EVENT_GUARD) {
+		event_mask = t->rseq_event_mask;
+		t->rseq_event_mask = 0;
+	}
 
 	return !!event_mask;
 }
diff --git a/tools/testing/selftests/rseq/rseq.c b/tools/testing/selftests/rseq/rseq.c
index 663a9cef1952..dcac5cbe7933 100644
--- a/tools/testing/selftests/rseq/rseq.c
+++ b/tools/testing/selftests/rseq/rseq.c
@@ -40,9 +40,9 @@
  * Define weak versions to play nice with binaries that are statically linked
  * against a libc that doesn't support registering its own rseq.
  */
-__weak ptrdiff_t __rseq_offset;
-__weak unsigned int __rseq_size;
-__weak unsigned int __rseq_flags;
+extern __weak ptrdiff_t __rseq_offset;
+extern __weak unsigned int __rseq_size;
+extern __weak unsigned int __rseq_flags;
 
 static const ptrdiff_t *libc_rseq_offset_p = &__rseq_offset;
 static const unsigned int *libc_rseq_size_p = &__rseq_size;
@@ -209,7 +209,7 @@ void rseq_init(void)
 	 * libc not having registered a restartable sequence.  Try to find the
 	 * symbols if that's the case.
 	 */
-	if (!*libc_rseq_size_p) {
+	if (!libc_rseq_size_p || !*libc_rseq_size_p) {
 		libc_rseq_offset_p = dlsym(RTLD_NEXT, "__rseq_offset");
 		libc_rseq_size_p = dlsym(RTLD_NEXT, "__rseq_size");
 		libc_rseq_flags_p = dlsym(RTLD_NEXT, "__rseq_flags");
Re: [GIT pull] core/rseq for v6.18-rc1
Posted by pr-tracker-bot@kernel.org 21 hours ago
The pull request you sent on Mon, 29 Sep 2025 11:28:56 +0200 (CEST):

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-rseq-2025-09-29

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/1d17e808cf2aad182f0eb2ea83e329e4a6795428

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html