Wed May 1 21:52:35 2019 UTC ()
Assert that debugger event is triggered only for userland LWP

All passing ATF ptrace(2) tests still pass.


(kamil)
diff -r1.354 -r1.355 src/sys/kern/kern_sig.c

cvs diff -r1.354 -r1.355 src/sys/kern/kern_sig.c (expand / switch to unified diff)

--- src/sys/kern/kern_sig.c 2019/05/01 18:01:54 1.354
+++ src/sys/kern/kern_sig.c 2019/05/01 21:52:35 1.355
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_sig.c,v 1.354 2019/05/01 18:01:54 kamil Exp $ */ 1/* $NetBSD: kern_sig.c,v 1.355 2019/05/01 21:52:35 kamil Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -60,27 +60,27 @@ @@ -60,27 +60,27 @@
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE. 63 * SUCH DAMAGE.
64 * 64 *
65 * @(#)kern_sig.c 8.14 (Berkeley) 5/14/95 65 * @(#)kern_sig.c 8.14 (Berkeley) 5/14/95
66 */ 66 */
67 67
68/* 68/*
69 * Signal subsystem. 69 * Signal subsystem.
70 */ 70 */
71 71
72#include <sys/cdefs.h> 72#include <sys/cdefs.h>
73__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.354 2019/05/01 18:01:54 kamil Exp $"); 73__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.355 2019/05/01 21:52:35 kamil Exp $");
74 74
75#include "opt_ptrace.h" 75#include "opt_ptrace.h"
76#include "opt_dtrace.h" 76#include "opt_dtrace.h"
77#include "opt_compat_sunos.h" 77#include "opt_compat_sunos.h"
78#include "opt_compat_netbsd.h" 78#include "opt_compat_netbsd.h"
79#include "opt_compat_netbsd32.h" 79#include "opt_compat_netbsd32.h"
80#include "opt_pax.h" 80#include "opt_pax.h"
81 81
82#define SIGPROP /* include signal properties table */ 82#define SIGPROP /* include signal properties table */
83#include <sys/param.h> 83#include <sys/param.h>
84#include <sys/signalvar.h> 84#include <sys/signalvar.h>
85#include <sys/proc.h> 85#include <sys/proc.h>
86#include <sys/ptrace.h> 86#include <sys/ptrace.h>
@@ -1532,26 +1532,27 @@ proc_stop_done(struct proc *p, int ppmas @@ -1532,26 +1532,27 @@ proc_stop_done(struct proc *p, int ppmas
1532 cv_broadcast(&p->p_pptr->p_waitcv); 1532 cv_broadcast(&p->p_pptr->p_waitcv);
1533 } 1533 }
1534} 1534}
1535 1535
1536void 1536void
1537eventswitch(int signo, int code) 1537eventswitch(int signo, int code)
1538{ 1538{
1539 struct lwp *l = curlwp; 1539 struct lwp *l = curlwp;
1540 struct proc *p = l->l_proc; 1540 struct proc *p = l->l_proc;
1541 1541
1542 KASSERT(mutex_owned(proc_lock)); 1542 KASSERT(mutex_owned(proc_lock));
1543 KASSERT(mutex_owned(p->p_lock)); 1543 KASSERT(mutex_owned(p->p_lock));
1544 KASSERT(l->l_stat == LSONPROC); 1544 KASSERT(l->l_stat == LSONPROC);
 1545 KASSERT((l->l_flag & LW_SYSTEM) == 0);
1545 KASSERT(p->p_nrlwps > 0); 1546 KASSERT(p->p_nrlwps > 0);
1546 1547
1547 /* 1548 /*
1548 * If there's a pending SIGKILL process it immediately. 1549 * If there's a pending SIGKILL process it immediately.
1549 */ 1550 */
1550 if (p->p_xsig == SIGKILL || 1551 if (p->p_xsig == SIGKILL ||
1551 sigismember(&p->p_sigpend.sp_set, SIGKILL)) { 1552 sigismember(&p->p_sigpend.sp_set, SIGKILL)) {
1552 mutex_exit(proc_lock); 1553 mutex_exit(proc_lock);
1553 return; 1554 return;
1554 } 1555 }
1555 1556
1556 p->p_xsig = signo; 1557 p->p_xsig = signo;
1557 p->p_sigctx.ps_faked = true; 1558 p->p_sigctx.ps_faked = true;