mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] signal: initialize k_sigaction in sys_signal()
@ 2026-11-23  9:13 Henry Martin
  2026-11-23 11:56 ` Oleg Nesterov
  2026-12-01 12:56 ` Christian Brauner
  0 siblings, 2 replies; 3+ messages in thread
From: Henry Martin @ 2026-11-23  9:13 UTC (permalink / raw)
  To: Oleg Nesterov, Andrew Morton, Christian Brauner
  Cc: linux-kernel, Henry Martin, stable

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] signal: initialize k_sigaction in sys_signal()
  2026-11-23  9:13 [PATCH] signal: initialize k_sigaction in sys_signal() Henry Martin
@ 2026-11-23 11:56 ` Oleg Nesterov
  2026-12-01 12:56 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Oleg Nesterov @ 2026-11-23 11:56 UTC (permalink / raw)
  To: Henry Martin; +Cc: Andrew Morton, Christian Brauner, linux-kernel, stable

On 11/23, Henry Martin wrote:
>
> Zero-initialize the whole struct so the fix also covers architectures
> that keep the restorer in ka_restorer.

...

>  SYSCALL_DEFINE2(signal, int, sig, __sighandler_t, handler)
>  {
> -	struct k_sigaction new_sa, old_sa;
> +	struct k_sigaction new_sa = { }, old_sa;
>  	int ret;

Acked-by: Oleg Nesterov <oleg@redhat.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] signal: initialize k_sigaction in sys_signal()
  2026-11-23  9:13 [PATCH] signal: initialize k_sigaction in sys_signal() Henry Martin
  2026-11-23 11:56 ` Oleg Nesterov
@ 2026-12-01 12:56 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-12-01 12:56 UTC (permalink / raw)
  To: Oleg Nesterov, Andrew Morton, Henry Martin; +Cc: linux-kernel, stable

On Mon, 23 Nov 2026 17:13:29 +0800, Henry Martin wrote:
> 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.
> 
> [...]

Applied to the master branch of the vfs/vfs.git tree.
Patches in the master branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: master

[1/1] signal: initialize k_sigaction in sys_signal()
      https://git.kernel.org/vfs/vfs/c/792614349ea5


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23  9:13 [PATCH] signal: initialize k_sigaction in sys_signal() Henry Martin
2026-11-23 11:56 ` Oleg Nesterov
2026-12-01 12:56 ` Christian Brauner

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®