Source-Changes-HG archive

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

[src/netbsd-9]: src/sys Pull up following revision(s) (requested by maxv in t...



details:   https://anonhg.NetBSD.org/src/rev/33dc62a587cf
branches:  netbsd-9
changeset: 460413:33dc62a587cf
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Oct 21 20:13:09 2019 +0000

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

        sys/kern/sys_sig.c: revision 1.48
        sys/sys/signalvar.h: revision 1.94
        sys/sys/signalvar.h: revision 1.95

Introduce sigaction_copy(), to copy sigaction structures without padding,
and use it in sigaction1(). This is to fix info leaks all at once in the
signal functions.

 -

Fix libkvm build.

diffstat:

 sys/kern/sys_sig.c  |   8 ++++----
 sys/sys/signalvar.h |  18 +++++++++++++++++-
 2 files changed, 21 insertions(+), 5 deletions(-)

diffs (75 lines):

diff -r 23c155b44ec1 -r 33dc62a587cf sys/kern/sys_sig.c
--- a/sys/kern/sys_sig.c        Mon Oct 21 20:09:22 2019 +0000
+++ b/sys/kern/sys_sig.c        Mon Oct 21 20:13:09 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_sig.c,v 1.47 2018/12/01 14:05:33 maxv Exp $        */
+/*     $NetBSD: sys_sig.c,v 1.47.4.1 2019/10/21 20:13:09 martin Exp $  */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.47 2018/12/01 14:05:33 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.47.4.1 2019/10/21 20:13:09 martin Exp $");
 
 #include "opt_dtrace.h"
 
@@ -466,7 +466,7 @@
 
        ps = p->p_sigacts;
        if (osa)
-               *osa = SIGACTION_PS(ps, signum);
+               sigaction_copy(osa, &SIGACTION_PS(ps, signum));
        if (!nsa)
                goto out;
 
@@ -476,7 +476,7 @@
                goto out;
        }
 
-       SIGACTION_PS(ps, signum) = *nsa;
+       sigaction_copy(&SIGACTION_PS(ps, signum), nsa);
        ps->sa_sigdesc[signum].sd_tramp = tramp;
        ps->sa_sigdesc[signum].sd_vers = vers;
        sigminusset(&sigcantmask, &SIGACTION_PS(ps, signum).sa_mask);
diff -r 23c155b44ec1 -r 33dc62a587cf sys/sys/signalvar.h
--- a/sys/sys/signalvar.h       Mon Oct 21 20:09:22 2019 +0000
+++ b/sys/sys/signalvar.h       Mon Oct 21 20:13:09 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: signalvar.h,v 1.93.2.2 2019/10/15 19:23:09 martin Exp $        */
+/*     $NetBSD: signalvar.h,v 1.93.2.3 2019/10/21 20:13:09 martin Exp $        */
 
 /*
  * Copyright (c) 1991, 1993
@@ -39,6 +39,10 @@
 #include <sys/mutex.h>
 #include <sys/stdbool.h>
 
+#ifndef _KERNEL
+#include <string.h>     /* Required for memset(3) and memcpy(3) prototypes */
+#endif /* _KERNEL */
+
 /*
  * Kernel signal definitions and data structures,
  * not exported to user programs.
@@ -93,6 +97,18 @@
 #define        SIGACTION_PS(ps, sig)   (ps->sa_sigdesc[(sig)].sd_sigact)
 
 /*
+ * Copy a sigaction structure without padding.
+ */
+static __inline void
+sigaction_copy(struct sigaction *dst, const struct sigaction *src)
+{
+       memset(dst, 0, sizeof(*dst));
+       dst->_sa_u._sa_handler = src->_sa_u._sa_handler;
+       memcpy(&dst->sa_mask, &src->sa_mask, sizeof(dst->sa_mask));
+       dst->sa_flags = src->sa_flags;
+}
+
+/*
  * Signal properties and actions.
  * The array below categorizes the signals and their default actions
  * according to the following properties:



Home | Main Index | Thread Index | Old Index