kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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
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>
© 2016 - 2026 Red Hat, Inc.