public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] do_notify_parent: sanitize the valid_signal() checks
@ 2026-02-22 15:23 Oleg Nesterov
  0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2026-02-22 15:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Christian Brauner, Mateusz Guzik, linux-kernel

The "sig" argument of do_notify_parent() must always be valid and it
does WARN_ON_ONCE(sig == -1) at the start. The 2nd valid_signal() check
before __send_signal_locked() must always be true or we have a bug.

This is confusing. Change do_notify_parent() to WARN and return early
if valid_signal(sig) is false.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/signal.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index ca23059a947d..a56a4413699b 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2173,7 +2173,8 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
 	bool autoreap = false;
 	u64 utime, stime;
 
-	WARN_ON_ONCE(sig == -1);
+	if (WARN_ON_ONCE(!valid_signal(sig)))
+		return false;
 
 	/* do_notify_parent_cldstop should have been called instead.  */
 	WARN_ON_ONCE(task_is_stopped_or_traced(tsk));
@@ -2254,7 +2255,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
 	 * Send with __send_signal as si_pid and si_uid are in the
 	 * parent's namespaces.
 	 */
-	if (valid_signal(sig) && sig)
+	if (sig)
 		__send_signal_locked(sig, &info, tsk->parent, PIDTYPE_TGID, false);
 	__wake_up_parent(tsk, tsk->parent);
 	spin_unlock_irqrestore(&psig->siglock, flags);
-- 
2.52.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-02-22 15:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-22 15:23 [PATCH] do_notify_parent: sanitize the valid_signal() checks Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox