Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7-0]: src/sys/arch Pull up following revision(s) (requested by ma...



details:   https://anonhg.NetBSD.org/src/rev/db070212652f
branches:  netbsd-7-0
changeset: 448004:db070212652f
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jan 30 13:32:56 2019 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #1677):

        sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
        sys/arch/arm/arm/sig_machdep.c: revision 1.51
        sys/arch/i386/i386/machdep.c: revision 1.813
        sys/arch/alpha/alpha/machdep.c: revision 1.352
        sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
        sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
        sys/arch/sparc64/sparc64/machdep.c: revision 1.289
        sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
        sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
        sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
        sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
        sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
        sys/arch/mips/mips/sig_machdep.c: revision 1.24
        sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
        sys/arch/vax/vax/sig_machdep.c: revision 1.23

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/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/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 ++++---
 15 files changed, 48 insertions(+), 43 deletions(-)

diffs (truncated from 486 to 300 lines):

diff -r e3255e3eb5fa -r db070212652f sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c    Tue Jan 29 08:32:36 2019 +0000
+++ b/sys/arch/alpha/alpha/machdep.c    Wed Jan 30 13:32:56 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.345.4.1 2016/11/01 20:27:51 snj Exp $ */
+/* $NetBSD: machdep.c,v 1.345.4.2 2019/01/30 13:32:57 martin 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.345.4.1 2016/11/01 20:27:51 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.345.4.2 2019/01/30 13:32:57 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1465,12 +1465,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 e3255e3eb5fa -r db070212652f sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c   Tue Jan 29 08:32:36 2019 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c   Wed Jan 30 13:32:56 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.92 2014/02/15 22:20:41 dsl Exp $        */
+/*     $NetBSD: netbsd32_machdep.c,v 1.92.8.1 2019/01/30 13:32:57 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.92 2014/02/15 22:20:41 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.92.8.1 2019/01/30 13:32:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -189,6 +189,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:
@@ -316,6 +318,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;
@@ -326,7 +329,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 e3255e3eb5fa -r db070212652f sys/arch/arm/arm/sig_machdep.c
--- a/sys/arch/arm/arm/sig_machdep.c    Tue Jan 29 08:32:36 2019 +0000
+++ b/sys/arch/arm/arm/sig_machdep.c    Wed Jan 30 13:32:56 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sig_machdep.c,v 1.47 2013/08/18 06:28:18 matt Exp $    */
+/*     $NetBSD: sig_machdep.c,v 1.47.6.1 2019/01/30 13:32:56 martin Exp $      */
 
 /*
  * Copyright (c) 1994-1998 Mark Brinicombe.
@@ -44,7 +44,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.47 2013/08/18 06:28:18 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.47.6.1 2019/01/30 13:32:56 martin Exp $");
 
 #include <sys/mount.h>         /* XXX only needed by syscallargs.h */
 #include <sys/cpu.h>
@@ -107,13 +107,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 e3255e3eb5fa -r db070212652f sys/arch/hppa/hppa/sig_machdep.c
--- a/sys/arch/hppa/hppa/sig_machdep.c  Tue Jan 29 08:32:36 2019 +0000
+++ b/sys/arch/hppa/hppa/sig_machdep.c  Wed Jan 30 13:32:56 2019 +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.25.34.1 2019/01/30 13:32:56 martin 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.25.34.1 2019/01/30 13:32:56 martin 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 e3255e3eb5fa -r db070212652f sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Tue Jan 29 08:32:36 2019 +0000
+++ b/sys/arch/i386/i386/machdep.c      Wed Jan 30 13:32:56 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.752.8.2 2018/01/22 19:40:25 snj Exp $    */
+/*     $NetBSD: machdep.c,v 1.752.8.3 2019/01/30 13:32:57 martin Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.752.8.2 2018/01/22 19:40:25 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.752.8.3 2019/01/30 13:32:57 martin Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -653,6 +653,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;
@@ -663,7 +664,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));
 
        if (tf->tf_eflags & PSL_VM)
                (*p->p_emul->e_syscall_intern)(p);
diff -r e3255e3eb5fa -r db070212652f sys/arch/m68k/m68k/sig_machdep.c
--- a/sys/arch/m68k/m68k/sig_machdep.c  Tue Jan 29 08:32:36 2019 +0000
+++ b/sys/arch/m68k/m68k/sig_machdep.c  Wed Jan 30 13:32:56 2019 +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.49.18.1 2019/01/30 13:32:57 martin 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.49.18.1 2019/01/30 13:32:57 martin 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 e3255e3eb5fa -r db070212652f sys/arch/mips/mips/netbsd32_machdep.c
--- a/sys/arch/mips/mips/netbsd32_machdep.c     Tue Jan 29 08:32:36 2019 +0000
+++ b/sys/arch/mips/mips/netbsd32_machdep.c     Wed Jan 30 13:32:56 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.11 2014/01/25 15:20:55 christos Exp $   */
+/*     $NetBSD: netbsd32_machdep.c,v 1.11.8.1 2019/01/30 13:32:57 martin 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.11 2014/01/25 15:20:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.11.8.1 2019/01/30 13:32:57 martin Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_coredump.h"
@@ -176,6 +176,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. */
@@ -195,7 +196,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 e3255e3eb5fa -r db070212652f sys/arch/mips/mips/sig_machdep.c
--- a/sys/arch/mips/mips/sig_machdep.c  Tue Jan 29 08:32:36 2019 +0000
+++ b/sys/arch/mips/mips/sig_machdep.c  Wed Jan 30 13:32:56 2019 +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.23.32.1 2019/01/30 13:32:57 martin 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.23.32.1 2019/01/30 13:32:57 martin Exp $"); 
 
 #include "opt_cputype.h"
 
@@ -85,12 +85,12 @@
 
        sf--;
 
+       memset(&ksf, 0, sizeof(ksf));
        ksf.sf_si._info = ksi->ksi_info;
        ksf.sf_uc.uc_flags = _UC_SIGMASK
            | (l->l_sigstk.ss_flags & SS_ONSTACK ? _UC_SETSTACK : _UC_CLRSTACK);
        ksf.sf_uc.uc_sigmask = *mask;
        ksf.sf_uc.uc_link = l->l_ctxlink;
-       memset(&ksf.sf_uc.uc_stack, 0, sizeof(ksf.sf_uc.uc_stack));
        sendsig_reset(l, signo);
 
        mutex_exit(p->p_lock);
diff -r e3255e3eb5fa -r db070212652f sys/arch/powerpc/powerpc/sig_machdep.c
--- a/sys/arch/powerpc/powerpc/sig_machdep.c    Tue Jan 29 08:32:36 2019 +0000
+++ b/sys/arch/powerpc/powerpc/sig_machdep.c    Wed Jan 30 13:32:56 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sig_machdep.c,v 1.43.14.1 2014/12/31 06:51:08 snj Exp $        */
+/*     $NetBSD: sig_machdep.c,v 1.43.14.1.2.1 2019/01/30 13:32:57 martin Exp $ */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.43.14.1 2014/12/31 06:51:08 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.43.14.1.2.1 2019/01/30 13:32:57 martin Exp $");
 
 #include "opt_ppcarch.h"
 #include "opt_altivec.h"
@@ -89,10 +89,10 @@
        sp &= ~(CALLFRAMELEN-1);
 
        /* Save register context. */
+       memset(&uc, 0, sizeof(uc));
        uc.uc_flags = _UC_SIGMASK;
        uc.uc_sigmask = *mask;



Home | Main Index | Thread Index | Old Index