From: Deepanshu Kartikey <kartikey406@gmail.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH -mm v2] do_notify_parent: sanitize the valid_signal() checks
Date: Tue, 17 Mar 2026 20:08:44 +0530 [thread overview]
Message-ID: <CADhLXY6NnOcScf6kC84Tf64=RL7Sfi+ntunz8B42Wm6iLVCivQ@mail.gmail.com> (raw)
In-Reply-To: <abld-ilvMEZ7VgMw@redhat.com>
On Tue, Mar 17, 2026 at 7:28 PM Oleg Nesterov <oleg@redhat.com> wrote:
>
> Now that kernel_clone() checks valid_signal(args->exit_signal), the "sig"
> argument of do_notify_parent() must always be valid or we have a bug.
>
> However, do_notify_parent() only checks that sig != -1 at the start, then
> it does another valid_signal() check before __send_signal_locked().
>
> 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 86aad7badb9a..683ef92f7234 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -2171,7 +2171,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));
> @@ -2252,7 +2253,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
>
>
Acked-by: Deepanshu Kartikey <Kartikey406@gmail.com>
next prev parent reply other threads:[~2026-03-17 14:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 15:19 [PATCH v3] kernel/fork: validate exit_signal in kernel_clone() Deepanshu Kartikey
2026-03-17 12:48 ` Oleg Nesterov
2026-03-17 14:10 ` Christian Brauner
2026-03-17 14:19 ` Oleg Nesterov
2026-03-17 13:58 ` [PATCH -mm v2] do_notify_parent: sanitize the valid_signal() checks Oleg Nesterov
2026-03-17 14:38 ` Deepanshu Kartikey [this message]
2026-03-17 18:34 ` Andrew Morton
2026-03-17 19:08 ` Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADhLXY6NnOcScf6kC84Tf64=RL7Sfi+ntunz8B42Wm6iLVCivQ@mail.gmail.com' \
--to=kartikey406@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox