Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Enhance locking of ptrace_update_lwp
details: https://anonhg.NetBSD.org/src/rev/ddf31fd6f9e8
branches: trunk
changeset: 461940:ddf31fd6f9e8
user: kamil <kamil%NetBSD.org@localhost>
date: Thu Jul 18 20:10:46 2019 +0000
description:
Enhance locking of ptrace_update_lwp
Replace lwp_delref() + mutex_enter() with: mutex_enter() + lwp_delref2().
This avoids extra taking and exiting from a mutex.
Add missing mutex_exit() for LW_SYSTEM.
Do not switch lwp for PT_SET_SIGINFO. This operation is not needed and
avoids panic for >2 LWPs as p_lock is attempted to be entered again in a
critical section.
diffstat:
sys/kern/sys_ptrace_common.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diffs (48 lines):
diff -r 9c5ecc1a254e -r ddf31fd6f9e8 sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c Thu Jul 18 18:21:45 2019 +0000
+++ b/sys/kern/sys_ptrace_common.c Thu Jul 18 20:10:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_ptrace_common.c,v 1.57 2019/06/29 11:37:17 maxv Exp $ */
+/* $NetBSD: sys_ptrace_common.c,v 1.58 2019/07/18 20:10:46 kamil Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.57 2019/06/29 11:37:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.58 2019/07/18 20:10:46 kamil Exp $");
#ifdef _KERNEL_OPT
#include "opt_ptrace.h"
@@ -552,9 +552,9 @@
if (lid == 0 || lid == (*lt)->l_lid || t->p_nlwps == 1)
return 0;
- lwp_delref(*lt);
+ mutex_enter(t->p_lock);
+ lwp_delref2(*lt);
- mutex_enter(t->p_lock);
*lt = lwp_find(t, lid);
if (*lt == NULL) {
mutex_exit(t->p_lock);
@@ -562,6 +562,7 @@
}
if ((*lt)->l_flag & LW_SYSTEM) {
+ mutex_exit(t->p_lock);
*lt = NULL;
return EINVAL;
}
@@ -601,9 +602,6 @@
if (psi.psi_siginfo.si_signo < 0 || psi.psi_siginfo.si_signo >= NSIG)
return EINVAL;
- if ((error = ptrace_update_lwp(t, lt, psi.psi_lwpid)) != 0)
- return error;
-
t->p_sigctx.ps_faked = true;
t->p_sigctx.ps_info = psi.psi_siginfo._info;
t->p_sigctx.ps_lwp = psi.psi_lwpid;
Home |
Main Index |
Thread Index |
Old Index