lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250813162824.100212248@linutronix.de>
Date: Wed, 13 Aug 2025 18:29:24 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Michael Jeanson <mjeanson@...icios.com>,
 Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
 Peter Zijlstra <peterz@...radead.org>,
 "Paul E. McKenney" <paulmck@...nel.org>,
 Boqun Feng <boqun.feng@...il.com>,
 Wei Liu <wei.liu@...nel.org>,
 Jens Axboe <axboe@...nel.dk>
Subject: [patch 05/11] rseq: Optimize the signal delivery path

Now that the individual event mask bits are gone, there is no point in
setting the event flag before invoking rseq_handle_notify_resume(). The
fact that the signal pointer is not NULL indicates that there is an event.

Simply drop the setting of the event bit and just fold the event in
rseq_handle_notify_resume() when the signal pointer is non-NULL.

Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: "Paul E. McKenney" <paulmck@...nel.org>
Cc: Boqun Feng <boqun.feng@...il.com>
---
 include/linux/resume_user_mode.h |    2 +-
 include/linux/rseq.h             |    9 +++------
 kernel/rseq.c                    |    7 ++++++-
 3 files changed, 10 insertions(+), 8 deletions(-)

--- a/include/linux/resume_user_mode.h
+++ b/include/linux/resume_user_mode.h
@@ -59,7 +59,7 @@ static inline void resume_user_mode_work
 	mem_cgroup_handle_over_high(GFP_KERNEL);
 	blkcg_maybe_throttle_current();
 
-	rseq_handle_notify_resume(NULL, regs);
+	rseq_handle_notify_resume(regs);
 }
 
 #endif /* LINUX_RESUME_USER_MODE_H */
--- a/include/linux/rseq.h
+++ b/include/linux/rseq.h
@@ -15,20 +15,17 @@ static inline void rseq_set_notify_resum
 
 void __rseq_handle_notify_resume(struct ksignal *sig, struct pt_regs *regs);
 
-static inline void rseq_handle_notify_resume(struct ksignal *ksig,
-					     struct pt_regs *regs)
+static inline void rseq_handle_notify_resume(struct pt_regs *regs)
 {
 	if (current->rseq)
-		__rseq_handle_notify_resume(ksig, regs);
+		__rseq_handle_notify_resume(NULL, regs);
 }
 
 static inline void rseq_signal_deliver(struct ksignal *ksig,
 				       struct pt_regs *regs)
 {
-	if (current->rseq) {
-		current->rseq_event_pending = true;
+	if (current->rseq)
 		__rseq_handle_notify_resume(ksig, regs);
-	}
 }
 
 static inline void rseq_notify_event(struct task_struct *t)
--- a/kernel/rseq.c
+++ b/kernel/rseq.c
@@ -451,6 +451,11 @@ void __rseq_handle_notify_resume(struct
 		 * again and this function is invoked another time _before_
 		 * the task is able to return to user mode.
 		 *
+		 * If directly invoked from the signal delivery path, @ksig
+		 * is not NULL and @regs are valid. The pending bit is not
+		 * set by the caller as it can easily be folded in during
+		 * the evaluation when @ksig != NULL.
+		 *
 		 * On a debug kernel, invoke the fixup code unconditionally
 		 * with the result handed in to allow the detection of
 		 * inconsistencies.
@@ -458,7 +463,7 @@ void __rseq_handle_notify_resume(struct
 		bool event;
 
 		scoped_guard(RSEQ_EVENT_GUARD) {
-			event = t->rseq_event_pending;
+			event = t->rseq_event_pending || !!ksig;
 			t->rseq_event_pending = false;
 		}
 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ