From: Kees Cook <keescook@chromium.org>
To: "haifeng.xu" <haifeng.xu@shopee.com>
Cc: brauner@kernel.org, ebiederm@xmission.com, oleg@redhat.com,
tglx@linutronix.de, peterz@infradead.org, elver@google.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] signal: Initialize the info in ksignal
Date: Thu, 1 Dec 2022 15:40:15 -0800 [thread overview]
Message-ID: <202212011537.371DD6639@keescook> (raw)
In-Reply-To: <20221128065606.19570-1-haifeng.xu@shopee.com>
On Mon, Nov 28, 2022 at 06:56:06AM +0000, haifeng.xu wrote:
> When handing the SIGNAL_GROUP_EXIT flag, the info in ksignal isn't cleared.
> However, the info acquired by dequeue_synchronous_signal/dequeue_signal is
> initialized and can be safely used. Fortunately, the fatal signal process
> just uses the si_signo and doesn't use any other member. Even so, the
> initialization before use is more safer.
Yeah, this patch seems correct -- get_signal() is usually called with
an uninitialized stack variable, and normally goes through dequeue_*
helpers which do a copy. The fatal path doesn't.
-Kees
> Signed-off-by: haifeng.xu <haifeng.xu@shopee.com>
> ---
> kernel/signal.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/signal.c b/kernel/signal.c
> index d140672185a4..b9b0c8c620e7 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -2693,6 +2693,7 @@ bool get_signal(struct ksignal *ksig)
> /* Has this task already been marked for death? */
> if ((signal->flags & SIGNAL_GROUP_EXIT) ||
> signal->group_exec_task) {
> + clear_siginfo(&ksig->info);
> ksig->info.si_signo = signr = SIGKILL;
> sigdelset(¤t->pending.signal, SIGKILL);
> trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO,
> --
> 2.25.1
>
--
Kees Cook
next prev parent reply other threads:[~2022-12-01 23:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 6:56 haifeng.xu
2022-12-01 23:40 ` Kees Cook [this message]
2022-12-01 23:42 ` Kees Cook
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=202212011537.371DD6639@keescook \
--to=keescook@chromium.org \
--cc=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=elver@google.com \
--cc=haifeng.xu@shopee.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®