summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_process.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/sys_process.c')
-rw-r--r--sys/kern/sys_process.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index a3a861f..5efec4f 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -442,7 +442,7 @@ ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entry *pve)
}
#ifdef COMPAT_FREEBSD32
-static int
+static int
ptrace_vm_entry32(struct thread *td, struct proc *p,
struct ptrace_vm_entry32 *pve32)
{
@@ -743,7 +743,18 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
*/
switch (req) {
case PT_TRACE_ME:
- /* Always legal. */
+ /*
+ * Always legal, when there is a parent process which
+ * could trace us. Otherwise, reject.
+ */
+ if ((p->p_flag & P_TRACED) != 0) {
+ error = EBUSY;
+ goto fail;
+ }
+ if (p->p_pptr == initproc) {
+ error = EPERM;
+ goto fail;
+ }
break;
case PT_ATTACH:
OpenPOWER on IntegriCloud