Source-Changes-HG archive

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

[src/trunk]: src/sys - Propagate the signal mask from the ucontext_t to the n...



details:   https://anonhg.NetBSD.org/src/rev/1c1ffc5516bc
branches:  trunk
changeset: 353138:1c1ffc5516bc
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 21 15:10:34 2017 +0000

description:
- Propagate the signal mask from the ucontext_t to the newly created thread
  as specified by _lwp_create(2)
- Reset the signal stack for threads created with _lwp_create(2)

diffstat:

 sys/compat/linux/common/linux_sched.c |   7 ++++---
 sys/compat/netbsd32/netbsd32_lwp.c    |  10 +++++++---
 sys/kern/kern_exec.c                  |   6 +++---
 sys/kern/kern_fork.c                  |   6 +++---
 sys/kern/kern_kthread.c               |   6 +++---
 sys/kern/kern_lwp.c                   |  13 +++++++------
 sys/kern/kern_sig.c                   |  12 ++++--------
 sys/kern/sys_aio.c                    |   6 +++---
 sys/kern/sys_lwp.c                    |  16 ++++++++++------
 sys/rump/librump/rumpkern/threads.c   |   9 +++++----
 sys/sys/lwp.h                         |   9 +++++----
 sys/sys/signal.h                      |   6 +++++-
 12 files changed, 59 insertions(+), 47 deletions(-)

diffs (truncated from 379 to 300 lines):

diff -r 538d00a0be74 -r 1c1ffc5516bc sys/compat/linux/common/linux_sched.c
--- a/sys/compat/linux/common/linux_sched.c     Fri Apr 21 15:06:37 2017 +0000
+++ b/sys/compat/linux/common/linux_sched.c     Fri Apr 21 15:10:34 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_sched.c,v 1.68 2015/07/03 02:24:28 christos Exp $        */
+/*     $NetBSD: linux_sched.c,v 1.69 2017/04/21 15:10:34 christos Exp $        */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.68 2015/07/03 02:24:28 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.69 2017/04/21 15:10:34 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -207,7 +207,8 @@
        }
 
        error = lwp_create(l, p, uaddr, LWP_DETACHED | LWP_PIDLID,
-           SCARG(uap, stack), 0, child_return, NULL, &l2, l->l_class);
+           SCARG(uap, stack), 0, child_return, NULL, &l2, l->l_class,
+           &l->l_sigmask, &l->l_sigstk);
        if (__predict_false(error)) {
                DPRINTF(("%s: lwp_create error=%d\n", __func__, error));
                atomic_dec_uint(&nprocs);
diff -r 538d00a0be74 -r 1c1ffc5516bc sys/compat/netbsd32/netbsd32_lwp.c
--- a/sys/compat/netbsd32/netbsd32_lwp.c        Fri Apr 21 15:06:37 2017 +0000
+++ b/sys/compat/netbsd32/netbsd32_lwp.c        Fri Apr 21 15:10:34 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_lwp.c,v 1.18 2015/05/15 07:56:25 matt Exp $   */
+/*     $NetBSD: netbsd32_lwp.c,v 1.19 2017/04/21 15:10:34 christos Exp $       */
 
 /*
  *  Copyright (c) 2005, 2006, 2007 The NetBSD Foundation.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_lwp.c,v 1.18 2015/05/15 07:56:25 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_lwp.c,v 1.19 2017/04/21 15:10:34 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -74,7 +74,11 @@
        if (error)
                goto fail;
 
-       error = do_lwp_create(l, newuc, SCARG(uap, flags), &lid);
+       const sigset_t *sigmask = newuc->uc_flags & _UC_SIGMASK ?
+           &newuc->uc_sigmask : &l->l_sigmask;
+
+       error = do_lwp_create(l, newuc, SCARG(uap, flags), &lid, sigmask,
+           &SS_INIT);
        if (error)
                goto fail;
 
diff -r 538d00a0be74 -r 1c1ffc5516bc sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Fri Apr 21 15:06:37 2017 +0000
+++ b/sys/kern/kern_exec.c      Fri Apr 21 15:10:34 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exec.c,v 1.441 2017/01/25 17:57:14 christos Exp $ */
+/*     $NetBSD: kern_exec.c,v 1.442 2017/04/21 15:10:34 christos Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.441 2017/01/25 17:57:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442 2017/04/21 15:10:34 christos Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -2531,7 +2531,7 @@
 
        /* create LWP */
        lwp_create(l1, p2, uaddr, 0, NULL, 0, spawn_return, spawn_data,
-           &l2, l1->l_class);
+           &l2, l1->l_class, &l1->l_sigmask, &l1->l_sigstk);
        l2->l_ctxlink = NULL;   /* reset ucontext link */
 
        /*
diff -r 538d00a0be74 -r 1c1ffc5516bc sys/kern/kern_fork.c
--- a/sys/kern/kern_fork.c      Fri Apr 21 15:06:37 2017 +0000
+++ b/sys/kern/kern_fork.c      Fri Apr 21 15:10:34 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_fork.c,v 1.201 2017/03/31 08:50:54 skrll Exp $    */
+/*     $NetBSD: kern_fork.c,v 1.202 2017/04/21 15:10:34 christos Exp $ */
 
 /*-
  * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.201 2017/03/31 08:50:54 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.202 2017/04/21 15:10:34 christos Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -434,7 +434,7 @@
         */
        lwp_create(l1, p2, uaddr, (flags & FORK_PPWAIT) ? LWP_VFORK : 0,
            stack, stacksize, (func != NULL) ? func : child_return, arg, &l2,
-           l1->l_class);
+           l1->l_class, &l1->l_sigmask, &l1->l_sigstk);
 
        /*
         * Inherit l_private from the parent.
diff -r 538d00a0be74 -r 1c1ffc5516bc sys/kern/kern_kthread.c
--- a/sys/kern/kern_kthread.c   Fri Apr 21 15:06:37 2017 +0000
+++ b/sys/kern/kern_kthread.c   Fri Apr 21 15:10:34 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_kthread.c,v 1.41 2015/04/21 11:10:29 pooka Exp $  */
+/*     $NetBSD: kern_kthread.c,v 1.42 2017/04/21 15:10:34 christos Exp $       */
 
 /*-
  * Copyright (c) 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.41 2015/04/21 11:10:29 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.42 2017/04/21 15:10:34 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -82,7 +82,7 @@
        }
 
        error = lwp_create(&lwp0, &proc0, uaddr, LWP_DETACHED, NULL,
-           0, func, arg, &l, lc);
+           0, func, arg, &l, lc, &lwp0.l_sigmask, &lwp0.l_sigstk);
        if (error) {
                uvm_uarea_system_free(uaddr);
                return error;
diff -r 538d00a0be74 -r 1c1ffc5516bc sys/kern/kern_lwp.c
--- a/sys/kern/kern_lwp.c       Fri Apr 21 15:06:37 2017 +0000
+++ b/sys/kern/kern_lwp.c       Fri Apr 21 15:10:34 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lwp.c,v 1.187 2017/01/14 19:32:10 kamil Exp $     */
+/*     $NetBSD: kern_lwp.c,v 1.188 2017/04/21 15:10:34 christos Exp $  */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -211,7 +211,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.187 2017/01/14 19:32:10 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.188 2017/04/21 15:10:34 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -760,8 +760,9 @@
  */
 int
 lwp_create(lwp_t *l1, proc_t *p2, vaddr_t uaddr, int flags,
-          void *stack, size_t stacksize, void (*func)(void *), void *arg,
-          lwp_t **rnewlwpp, int sclass)
+    void *stack, size_t stacksize, void (*func)(void *), void *arg,
+    lwp_t **rnewlwpp, int sclass, const sigset_t *sigmask,
+    const stack_t *sigstk)
 {
        struct lwp *l2, *isfree;
        turnstile_t *ts;
@@ -904,8 +905,8 @@
        } else
                l2->l_prflag = 0;
 
-       l2->l_sigstk = l1->l_sigstk;
-       l2->l_sigmask = l1->l_sigmask;
+       l2->l_sigstk = *sigstk;
+       l2->l_sigmask = *sigmask;
        TAILQ_INIT(&l2->l_sigpend.sp_info);
        sigemptyset(&l2->l_sigpend.sp_set);
 
diff -r 538d00a0be74 -r 1c1ffc5516bc sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Fri Apr 21 15:06:37 2017 +0000
+++ b/sys/kern/kern_sig.c       Fri Apr 21 15:10:34 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.335 2017/03/31 08:47:04 martin Exp $    */
+/*     $NetBSD: kern_sig.c,v 1.336 2017/04/21 15:10:35 christos Exp $  */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.335 2017/03/31 08:47:04 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.336 2017/04/21 15:10:35 christos Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -347,9 +347,7 @@
         */
        l = LIST_FIRST(&p->p_lwps);
        l->l_sigwaited = NULL;
-       l->l_sigstk.ss_flags = SS_DISABLE;
-       l->l_sigstk.ss_size = 0;
-       l->l_sigstk.ss_sp = 0;
+       l->l_sigstk = SS_INIT;
        ksiginfo_queue_init(&l->l_sigpend.sp_info);
        sigemptyset(&l->l_sigpend.sp_set);
 
@@ -417,9 +415,7 @@
         */
        l = LIST_FIRST(&p->p_lwps);
        l->l_sigwaited = NULL;
-       l->l_sigstk.ss_flags = SS_DISABLE;
-       l->l_sigstk.ss_size = 0;
-       l->l_sigstk.ss_sp = 0;
+       l->l_sigstk = SS_INIT;
        ksiginfo_queue_init(&l->l_sigpend.sp_info);
        sigemptyset(&l->l_sigpend.sp_set);
        mutex_exit(p->p_lock);
diff -r 538d00a0be74 -r 1c1ffc5516bc sys/kern/sys_aio.c
--- a/sys/kern/sys_aio.c        Fri Apr 21 15:06:37 2017 +0000
+++ b/sys/kern/sys_aio.c        Fri Apr 21 15:10:34 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_aio.c,v 1.41 2016/07/07 06:55:43 msaitoh Exp $     */
+/*     $NetBSD: sys_aio.c,v 1.42 2017/04/21 15:10:35 christos Exp $    */
 
 /*
  * Copyright (c) 2007 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.41 2016/07/07 06:55:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.42 2017/04/21 15:10:35 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -211,7 +211,7 @@
                return EAGAIN;
        }
        error = lwp_create(curlwp, p, uaddr, 0, NULL, 0, aio_worker,
-           NULL, &l, curlwp->l_class);
+           NULL, &l, curlwp->l_class, &curlwp->l_sigmask, &curlwp->l_sigstk);
        if (error != 0) {
                uvm_uarea_free(uaddr);
                aio_exit(p, aio);
diff -r 538d00a0be74 -r 1c1ffc5516bc sys/kern/sys_lwp.c
--- a/sys/kern/sys_lwp.c        Fri Apr 21 15:06:37 2017 +0000
+++ b/sys/kern/sys_lwp.c        Fri Apr 21 15:10:34 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_lwp.c,v 1.58 2017/01/15 01:28:14 maya Exp $        */
+/*     $NetBSD: sys_lwp.c,v 1.59 2017/04/21 15:10:35 christos Exp $    */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.58 2017/01/15 01:28:14 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.59 2017/04/21 15:10:35 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -70,7 +70,8 @@
 }
 
 int
-do_lwp_create(lwp_t *l, void *arg, u_long flags, lwpid_t *new_lwp)
+do_lwp_create(lwp_t *l, void *arg, u_long flags, lwpid_t *new_lwp,
+    const sigset_t *sigmask, const stack_t *sigstk)
 {
        struct proc *p = l->l_proc;
        struct lwp *l2;
@@ -84,8 +85,8 @@
        if (__predict_false(uaddr == 0))
                return ENOMEM;
 
-       error = lwp_create(l, p, uaddr, flags & LWP_DETACHED,
-           NULL, 0, p->p_emul->e_startlwp, arg, &l2, l->l_class);
+       error = lwp_create(l, p, uaddr, flags & LWP_DETACHED, NULL, 0,
+           p->p_emul->e_startlwp, arg, &l2, l->l_class, sigmask);
        if (__predict_false(error)) {
                uvm_uarea_free(uaddr);
                return error;
@@ -152,7 +153,10 @@
        if (error)
                goto fail;
 
-       error = do_lwp_create(l, newuc, SCARG(uap, flags), &lid);
+       const sigset_t *sigmask = newuc->uc_flags & _UC_SIGMASK ?
+           &newuc->uc_sigmask : &l->l_sigmask;
+       error = do_lwp_create(l, newuc, SCARG(uap, flags), &lid, sigmask,
+           &SS_INIT);
        if (error)
                goto fail;
 
diff -r 538d00a0be74 -r 1c1ffc5516bc sys/rump/librump/rumpkern/threads.c



Home | Main Index | Thread Index | Old Index