mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Henry Martin <bsdhenrymartin@gmail.com>
To: Oleg Nesterov <oleg@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Christian Brauner <brauner@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Henry Martin <bsdhenrymartin@gmail.com>,
	stable@vger.kernel.org
Subject: [PATCH] signal: initialize k_sigaction in sys_signal()
Date: Mon, 23 Nov 2026 17:13:29 +0800	[thread overview]
Message-ID: <20261123091329.3658965-1-bsdhenrymartin@gmail.com> (raw)

sys_signal() builds a struct k_sigaction on the stack and only sets
sa_handler, sa_flags and sa_mask.  sa_restorer (and, on sparc,
ka_restorer) keep whatever the previous syscall left at the same stack
slot, and do_sigaction() stores the whole struct into
sighand->action[sig - 1].

A 32-bit process can read sa_restorer back through compat
rt_sigaction(oact), which always copies it to userspace.  The leaked low
32 bits are stale kernel stack content, in practice a kernel text return
address, so the two syscalls reveal the KASLR slide.

Zero-initialize the whole struct so the fix also covers architectures
that keep the restorer in ka_restorer.

This issue was discovered by Tencent CodeBuddy Security.

Cc: stable@vger.kernel.org
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
 kernel/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index dd770e68faee..460dd4d1d548 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -4894,7 +4894,7 @@ SYSCALL_DEFINE1(ssetmask, int, newmask)
  */
 SYSCALL_DEFINE2(signal, int, sig, __sighandler_t, handler)
 {
-	struct k_sigaction new_sa, old_sa;
+	struct k_sigaction new_sa = { }, old_sa;
 	int ret;
 
 	new_sa.sa.sa_handler = handler;
-- 
2.53.0


                 reply	other threads:[~2026-11-23  9:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261123091329.3658965-1-bsdhenrymartin@gmail.com \
    --to=bsdhenrymartin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=stable@vger.kernel.org \
    /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®