Module Name:    src
Committed By:   martin
Date:           Mon Oct 21 20:13:09 UTC 2019

Modified Files:
        src/sys/kern [netbsd-9]: sys_sig.c
        src/sys/sys [netbsd-9]: signalvar.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.47.4.1 src/sys/kern/sys_sig.c
cvs rdiff -u -r1.93.2.2 -r1.93.2.3 src/sys/sys/signalvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/sys_sig.c
diff -u src/sys/kern/sys_sig.c:1.47 src/sys/kern/sys_sig.c:1.47.4.1
--- src/sys/kern/sys_sig.c:1.47	Sat Dec  1 14:05:33 2018
+++ src/sys/kern/sys_sig.c	Mon Oct 21 20:13:09 2019
@@ -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 @@ sigaction1(struct lwp *l, int signum, co
 
 	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 @@ sigaction1(struct lwp *l, int signum, co
 		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);

Index: src/sys/sys/signalvar.h
diff -u src/sys/sys/signalvar.h:1.93.2.2 src/sys/sys/signalvar.h:1.93.2.3
--- src/sys/sys/signalvar.h:1.93.2.2	Tue Oct 15 19:23:09 2019
+++ src/sys/sys/signalvar.h	Mon Oct 21 20:13:09 2019
@@ -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 @@ struct sigctx {
 #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:

Reply via email to