Module Name:src
Committed By: bouyer
Date: Sun Nov 15 20:42:39 UTC 2015
Modified Files:
src/sys/compat/linux/arch/arm [netbsd-6-1]: linux_ptrace.c
src/sys/compat/linux/arch/i386 [netbsd-6-1]: linux_ptrace.c
src/sys/compat/linux/arch/powerpc [netbsd-6-1]: linux_ptrace.c
Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #1335):
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.31
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.19
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.29
Don't release proc_lock until we're done looking at things that are
protected by the lock, particularly p_stat and p_waited. Found by
Robert Elz.
XXX Pullup to NetBSD-7, -6, -6-0, and -6-1
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.16.20.1 src/sys/compat/linux/arch/arm/linux_ptrace.c
cvs rdiff -u -r1.26 -r1.26.28.1 src/sys/compat/linux/arch/i386/linux_ptrace.c
cvs rdiff -u -r1.23 -r1.23.28.1 \
src/sys/compat/linux/arch/powerpc/linux_ptrace.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/linux/arch/arm/linux_ptrace.c
diff -u src/sys/compat/linux/arch/arm/linux_ptrace.c:1.16 src/sys/compat/linux/arch/arm/linux_ptrace.c:1.16.20.1
--- src/sys/compat/linux/arch/arm/linux_ptrace.c:1.16 Wed Jul 7 01:30:33 2010
+++ src/sys/compat/linux/arch/arm/linux_ptrace.c Sun Nov 15 20:42:39 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_ptrace.c,v 1.16 2010/07/07 01:30:33 chs Exp $ */
+/* $NetBSD: linux_ptrace.c,v 1.16.20.1 2015/11/15 20:42:39 bouyer Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include
-__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.16 2010/07/07 01:30:33 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.16.20.1 2015/11/15 20:42:39 bouyer Exp $");
#include
#include
@@ -140,7 +140,6 @@ linux_sys_ptrace_arch(struct lwp *l, con
goto out;
}
mutex_enter(t->p_lock);
- mutex_exit(proc_lock);
/*
* You cannot do what you want to the process if:
@@ -148,6 +147,7 @@ linux_sys_ptrace_arch(struct lwp *l, con
*/
if (!ISSET(t->p_slflag, PSL_TRACED)) {
mutex_exit(t->p_lock);
+ mutex_exit(proc_lock);
error = EPERM;
goto out;
}
@@ -160,9 +160,11 @@ linux_sys_ptrace_arch(struct lwp *l, con
if (ISSET(t->p_slflag, PSL_FSTRACE) || t->p_pptr != p ||
t->p_stat != SSTOP || !t->p_waited) {
mutex_exit(t->p_lock);
+ mutex_exit(proc_lock);
error = EBUSY;
goto out;
}
+ mutex_exit(proc_lock);
/* XXX: ptrace needs revamp for multi-threading support. */
if (t->p_nlwps > 1) {
mutex_exit(t->p_lock);
Index: src/sys/compat/linux/arch/i386/linux_ptrace.c
diff -u src/sys/compat/linux/arch/i386/linux_ptrace.c:1.26 src/sys/compat/linux/arch/i386/linux_ptrace.c:1.26.28.1
--- src/sys/compat/linux/arch/i386/linux_ptrace.c:1.26 Wed Jul 7 01:30:34 2010
+++ src/sys/compat/linux/arch/i386/linux_ptrace.c Sun Nov 15 20:42:39 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_ptrace.c,v 1.26 2010/07/07 01:30:34 chs Exp $ */
+/* $NetBSD: linux_ptrace.c,v 1.26.28.1 2015/11/15 20:42:39 bouyer Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include
-__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.26 2010/07/07 01:30:34 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.26.28.1 2015/11/15 20:42:39 bouyer Exp $");
#include
#include
@@ -184,7 +184,6 @@ linux_sys_ptrace_arch(struct lwp *l, con
return ESRCH;
}
mutex_enter(t->p_lock);
- mutex_exit(proc_lock);
/*
* You cannot do what you want to the process if:
@@ -192,6 +191,7 @@ linux_sys_ptrace_arch(struct lwp *l, con
*/
if (!ISSET(t->p_slflag, PSL_TRACED)) {
mutex_exit(t->p_lock);
+ mutex_exit(proc_lock);
error = EPERM;
goto out;
}
@@ -204,9 +204,11 @@ linux_sys_ptrace_arch(struct lwp *l, con
if (ISSET(t->p_slflag, PSL_FSTRACE) || t->p_pptr != p ||
t->p_stat != SSTOP || !t->p_waited) {
mutex_exit(t->p_lock);
+ mutex_exit(proc_lock);
error = EBUSY;
goto out;
}
+ mutex_exit(proc_lock);
/* XXX: ptrace needs revamp for multi-threading support. */
if (t->p_nlwps > 1) {
mutex_exit(t->p_lock);
Index: src/sys/compat/linux/arch/powerpc/linux_ptrace.c
diff -u src/sys/compat/linux/arch/powerpc/linux_ptrace.c:1.23 src/sys/compat/linux/arch/powerpc/linux_ptrace.c:1.23.28.1
--- src/sys/compat/linux/arch/powerpc/linux_ptrace.c:1.23 Thu Jul 1 02:38:28 2010
+++ src/sys/compat/linux/arch/powerpc/linux_ptrace.c Sun Nov 15 20:42:39 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_ptrace.c,v 1.23 2010/07/01 02:38:28 rmind Exp $ */
+/* $NetBSD: linux_ptrace.c,v 1.23.28.1 2015/11/15 20:42:39 bouyer Exp $ */
/*-
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include
-__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.23 2010/07/01 02:38:28 rmind Exp $");
+__KERNEL_RCSID(0, "$NetB