Source-Changes-HG archive

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

[src/trunk]: src/sys Introduce sigaction_copy(), to copy sigaction structures...



details:   https://anonhg.NetBSD.org/src/rev/a33a0e10fb43
branches:  trunk
changeset: 1003281:a33a0e10fb43
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Sep 08 07:00:20 2019 +0000

description:
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.

diffstat:

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

diffs (64 lines):

diff -r 3721ba3426ef -r a33a0e10fb43 sys/kern/sys_sig.c
--- a/sys/kern/sys_sig.c        Sun Sep 08 05:55:15 2019 +0000
+++ b/sys/kern/sys_sig.c        Sun Sep 08 07:00:20 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.48 2019/09/08 07:00:20 maxv 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.48 2019/09/08 07:00:20 maxv 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 3721ba3426ef -r a33a0e10fb43 sys/sys/signalvar.h
--- a/sys/sys/signalvar.h       Sun Sep 08 05:55:15 2019 +0000
+++ b/sys/sys/signalvar.h       Sun Sep 08 07:00:20 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: signalvar.h,v 1.93 2019/05/03 22:34:21 kamil Exp $     */
+/*     $NetBSD: signalvar.h,v 1.94 2019/09/08 07:00:20 maxv Exp $      */
 
 /*
  * Copyright (c) 1991, 1993
@@ -93,6 +93,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