linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "haifeng.xu" <haifeng.xu@shopee.com>
To: brauner@kernel.org
Cc: ebiederm@xmission.com, oleg@redhat.com, keescook@chromium.org,
	tglx@linutronix.de, peterz@infradead.org, elver@google.com,
	linux-kernel@vger.kernel.org,
	"haifeng.xu" <haifeng.xu@shopee.com>
Subject: [PATCH] signal: Initialize the info in ksignal
Date: Mon, 28 Nov 2022 06:56:06 +0000	[thread overview]
Message-ID: <20221128065606.19570-1-haifeng.xu@shopee.com> (raw)

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.

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(&current->pending.signal, SIGKILL);
 			trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO,
-- 
2.25.1


             reply	other threads:[~2022-11-28  6:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28  6:56 haifeng.xu [this message]
2022-12-01 23:40 ` [PATCH] signal: Initialize the info in ksignal Kees Cook
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=20221128065606.19570-1-haifeng.xu@shopee.com \
    --to=haifeng.xu@shopee.com \
    --cc=brauner@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=elver@google.com \
    --cc=keescook@chromium.org \
    --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;
as well as URLs for NNTP newsgroup(s).