Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Fix widespread leak in the sendsig_siginfo() functi...
details: https://anonhg.NetBSD.org/src/rev/924739305c6e
branches: trunk
changeset: 994905:924739305c6e
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Nov 27 14:09:53 2018 +0000
description:
Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.
I can't compile-test on each architecture, but there should be no
breakage (tm).
Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
diffstat:
sys/arch/aarch64/aarch64/netbsd32_machdep.c | 7 ++++---
sys/arch/alpha/alpha/machdep.c | 7 +++----
sys/arch/amd64/amd64/netbsd32_machdep.c | 8 +++++---
sys/arch/arm/arm/sig_machdep.c | 6 +++---
sys/arch/hppa/hppa/sig_machdep.c | 6 +++---
sys/arch/i386/i386/machdep.c | 6 +++---
sys/arch/m68k/m68k/sig_machdep.c | 6 +++---
sys/arch/mips/mips/netbsd32_machdep.c | 6 +++---
sys/arch/mips/mips/sig_machdep.c | 6 +++---
sys/arch/powerpc/powerpc/sig_machdep.c | 6 +++---
sys/arch/riscv/riscv/sig_machdep.c | 3 ++-
sys/arch/sh3/sh3/sh3_machdep.c | 6 +++---
sys/arch/sparc64/sparc64/machdep.c | 6 +++---
sys/arch/sparc64/sparc64/netbsd32_machdep.c | 5 +++--
sys/arch/usermode/target/i386/cpu_i386.c | 5 +++--
sys/arch/usermode/target/x86_64/cpu_x86_64.c | 5 +++--
sys/arch/vax/vax/sig_machdep.c | 7 ++++---
17 files changed, 54 insertions(+), 47 deletions(-)
diffs (truncated from 541 to 300 lines):
diff -r 3e44f3af788b -r 924739305c6e sys/arch/aarch64/aarch64/netbsd32_machdep.c
--- a/sys/arch/aarch64/aarch64/netbsd32_machdep.c Tue Nov 27 10:38:14 2018 +0000
+++ b/sys/arch/aarch64/aarch64/netbsd32_machdep.c Tue Nov 27 14:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.2 2018/10/12 01:28:57 ryo Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.3 2018/11/27 14:09:53 maxv Exp $ */
/*
* Copyright (c) 2018 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.2 2018/10/12 01:28:57 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.3 2018/11/27 14:09:53 maxv Exp $");
#include "opt_compat_netbsd.h"
@@ -223,6 +223,8 @@
fp = (struct netbsd32_sigframe_siginfo *)sp;
fp = (struct netbsd32_sigframe_siginfo *)STACK_ALIGN(fp - 1, 8);
+ memset(&frame, 0, sizeof(frame));
+
/* XXX: netbsd32_ksi_to_si32 */
netbsd32_si_to_si32(&frame.sf_si, (const siginfo_t *)&ksi->ksi_info);
@@ -231,7 +233,6 @@
frame.sf_uc.uc_link = (uint32_t)(uintptr_t)l->l_ctxlink;
frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK) ?
_UC_SETSTACK : _UC_CLRSTACK;
- memset(&frame.sf_uc.uc_stack, 0, sizeof(frame.sf_uc.uc_stack));
sendsig_reset(l, signo);
mutex_exit(p->p_lock);
diff -r 3e44f3af788b -r 924739305c6e sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c Tue Nov 27 10:38:14 2018 +0000
+++ b/sys/arch/alpha/alpha/machdep.c Tue Nov 27 14:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.351 2018/09/03 16:29:22 riastradh Exp $ */
+/* $NetBSD: machdep.c,v 1.352 2018/11/27 14:09:53 maxv Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.351 2018/09/03 16:29:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.352 2018/11/27 14:09:53 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1467,12 +1467,11 @@
#endif
/* Build stack frame for signal trampoline. */
-
+ memset(&frame, 0, sizeof(frame));
frame.sf_si._info = ksi->ksi_info;
frame.sf_uc.uc_flags = _UC_SIGMASK;
frame.sf_uc.uc_sigmask = *mask;
frame.sf_uc.uc_link = l->l_ctxlink;
- memset(&frame.sf_uc.uc_stack, 0, sizeof(frame.sf_uc.uc_stack));
sendsig_reset(l, sig);
mutex_exit(p->p_lock);
cpu_getmcontext(l, &frame.sf_uc.uc_mcontext, &frame.sf_uc.uc_flags);
diff -r 3e44f3af788b -r 924739305c6e sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c Tue Nov 27 10:38:14 2018 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c Tue Nov 27 14:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.116 2018/07/26 09:29:08 maxv Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.117 2018/11/27 14:09:53 maxv Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.116 2018/07/26 09:29:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.117 2018/11/27 14:09:53 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -225,6 +225,8 @@
fp = (struct netbsd32_sigframe_sigcontext *)tf->tf_rsp;
fp--;
+ memset(&frame, 0, sizeof(frame));
+
/* Build stack frame for signal trampoline. */
switch (ps->sa_sigdesc[sig].sd_vers) {
case 0:
@@ -324,6 +326,7 @@
break;
}
+ memset(&frame, 0, sizeof(frame));
frame.sf_ra = (uint32_t)(uintptr_t)ps->sa_sigdesc[sig].sd_tramp;
frame.sf_signum = sig;
frame.sf_sip = (uint32_t)(uintptr_t)&fp->sf_si;
@@ -334,7 +337,6 @@
frame.sf_uc.uc_link = (uint32_t)(uintptr_t)l->l_ctxlink;
frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK)
? _UC_SETSTACK : _UC_CLRSTACK;
- memset(&frame.sf_uc.uc_stack, 0, sizeof(frame.sf_uc.uc_stack));
sendsig_reset(l, sig);
mutex_exit(p->p_lock);
diff -r 3e44f3af788b -r 924739305c6e sys/arch/arm/arm/sig_machdep.c
--- a/sys/arch/arm/arm/sig_machdep.c Tue Nov 27 10:38:14 2018 +0000
+++ b/sys/arch/arm/arm/sig_machdep.c Tue Nov 27 14:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sig_machdep.c,v 1.50 2018/01/24 09:04:44 skrll Exp $ */
+/* $NetBSD: sig_machdep.c,v 1.51 2018/11/27 14:09:53 maxv Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@@ -44,7 +44,7 @@
#include <sys/param.h>
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.50 2018/01/24 09:04:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.51 2018/11/27 14:09:53 maxv Exp $");
#include <sys/mount.h> /* XXX only needed by syscallargs.h */
#include <sys/cpu.h>
@@ -105,13 +105,13 @@
fp = (struct sigframe_siginfo *)STACK_ALIGN(fp, STACK_ALIGNBYTES);
/* populate the siginfo frame */
+ memset(&frame, 0, sizeof(frame));
frame.sf_si._info = ksi->ksi_info;
frame.sf_uc.uc_flags = _UC_SIGMASK;
frame.sf_uc.uc_sigmask = *mask;
frame.sf_uc.uc_link = l->l_ctxlink;
frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK)
? _UC_SETSTACK : _UC_CLRSTACK;
- memset(&frame.sf_uc.uc_stack, 0, sizeof(frame.sf_uc.uc_stack));
sendsig_reset(l, sig);
mutex_exit(p->p_lock);
diff -r 3e44f3af788b -r 924739305c6e sys/arch/hppa/hppa/sig_machdep.c
--- a/sys/arch/hppa/hppa/sig_machdep.c Tue Nov 27 10:38:14 2018 +0000
+++ b/sys/arch/hppa/hppa/sig_machdep.c Tue Nov 27 14:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sig_machdep.c,v 1.25 2011/02/08 20:20:15 rmind Exp $ */
+/* $NetBSD: sig_machdep.c,v 1.26 2018/11/27 14:09:53 maxv Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.25 2011/02/08 20:20:15 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.26 2018/11/27 14:09:53 maxv Exp $");
#include "opt_compat_netbsd.h"
@@ -141,13 +141,13 @@
break;
}
+ memset(&frame, 0, sizeof(frame));
frame.sf_si._info = ksi->ksi_info;
frame.sf_uc.uc_flags = _UC_SIGMASK |
((l->l_sigstk.ss_flags & SS_ONSTACK) ?
_UC_SETSTACK : _UC_CLRSTACK);
frame.sf_uc.uc_sigmask = *mask;
frame.sf_uc.uc_link = l->l_ctxlink;
- memset(&frame.sf_uc.uc_stack, 0, sizeof(frame.sf_uc.uc_stack));
sendsig_reset(l, sig);
mutex_exit(p->p_lock);
cpu_getmcontext(l, &frame.sf_uc.uc_mcontext, &frame.sf_uc.uc_flags);
diff -r 3e44f3af788b -r 924739305c6e sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Tue Nov 27 10:38:14 2018 +0000
+++ b/sys/arch/i386/i386/machdep.c Tue Nov 27 14:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.812 2018/10/18 04:22:22 cherry Exp $ */
+/* $NetBSD: machdep.c,v 1.813 2018/11/27 14:09:53 maxv Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.812 2018/10/18 04:22:22 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.813 2018/11/27 14:09:53 maxv Exp $");
#include "opt_beep.h"
#include "opt_compat_freebsd.h"
@@ -689,6 +689,7 @@
fp--;
+ memset(&frame, 0, sizeof(frame));
frame.sf_ra = (int)ps->sa_sigdesc[sig].sd_tramp;
frame.sf_signum = sig;
frame.sf_sip = &fp->sf_si;
@@ -699,7 +700,6 @@
frame.sf_uc.uc_link = l->l_ctxlink;
frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK)
? _UC_SETSTACK : _UC_CLRSTACK;
- memset(&frame.sf_uc.uc_stack, 0, sizeof(frame.sf_uc.uc_stack));
sendsig_reset(l, sig);
diff -r 3e44f3af788b -r 924739305c6e sys/arch/m68k/m68k/sig_machdep.c
--- a/sys/arch/m68k/m68k/sig_machdep.c Tue Nov 27 10:38:14 2018 +0000
+++ b/sys/arch/m68k/m68k/sig_machdep.c Tue Nov 27 14:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sig_machdep.c,v 1.49 2012/05/21 14:15:18 martin Exp $ */
+/* $NetBSD: sig_machdep.c,v 1.50 2018/11/27 14:09:54 maxv Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -40,7 +40,7 @@
#include "opt_m68k_arch.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.49 2012/05/21 14:15:18 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.50 2018/11/27 14:09:54 maxv Exp $");
#define __M68K_SIGNAL_PRIVATE
@@ -159,6 +159,7 @@
fp--;
+ memset(&kf, 0, sizeof(kf));
kf.sf_ra = (int)ps->sa_sigdesc[sig].sd_tramp;
kf.sf_signum = sig;
kf.sf_sip = &fp->sf_si;
@@ -169,7 +170,6 @@
kf.sf_uc.uc_link = l->l_ctxlink;
kf.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK)
? _UC_SETSTACK : _UC_CLRSTACK;
- memset(&kf.sf_uc.uc_stack, 0, sizeof(kf.sf_uc.uc_stack));
sendsig_reset(l, sig);
mutex_exit(p->p_lock);
cpu_getmcontext(l, &kf.sf_uc.uc_mcontext, &kf.sf_uc.uc_flags);
diff -r 3e44f3af788b -r 924739305c6e sys/arch/mips/mips/netbsd32_machdep.c
--- a/sys/arch/mips/mips/netbsd32_machdep.c Tue Nov 27 10:38:14 2018 +0000
+++ b/sys/arch/mips/mips/netbsd32_machdep.c Tue Nov 27 14:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.15 2017/10/31 12:37:23 martin Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.16 2018/11/27 14:09:54 maxv Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.15 2017/10/31 12:37:23 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.16 2018/11/27 14:09:54 maxv Exp $");
#include "opt_compat_netbsd.h"
#include "opt_coredump.h"
@@ -177,6 +177,7 @@
sfp--;
+ memset(&sf, 0, sizeof(sf));
netbsd32_si_to_si32(&sf.sf_si, (const siginfo_t *)&ksi->ksi_info);
/* Build stack frame for signal trampoline. */
@@ -196,7 +197,6 @@
? _UC_SETSTACK : _UC_CLRSTACK);
sf.sf_uc.uc_sigmask = *mask;
sf.sf_uc.uc_link = (intptr_t)l->l_ctxlink;
- memset(&sf.sf_uc.uc_stack, 0, sizeof(sf.sf_uc.uc_stack));
sfsz = offsetof(struct sigframe_siginfo32, sf_uc.uc_mcontext);
if (p->p_md.md_abi == _MIPS_BSD_API_O32)
sfsz += sizeof(mcontext_o32_t);
diff -r 3e44f3af788b -r 924739305c6e sys/arch/mips/mips/sig_machdep.c
--- a/sys/arch/mips/mips/sig_machdep.c Tue Nov 27 10:38:14 2018 +0000
+++ b/sys/arch/mips/mips/sig_machdep.c Tue Nov 27 14:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sig_machdep.c,v 1.23 2011/07/10 23:21:59 matt Exp $ */
+/* $NetBSD: sig_machdep.c,v 1.24 2018/11/27 14:09:54 maxv Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.23 2011/07/10 23:21:59 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.24 2018/11/27 14:09:54 maxv Exp $");
#include "opt_cputype.h"
@@ -85,12 +85,12 @@
sf--;
Home |
Main Index |
Thread Index |
Old Index