svn commit: r290324 - stable/10/sys/kern
Konstantin Belousov
kib at FreeBSD.org
Tue Nov 3 08:31:02 UTC 2015
Author: kib
Date: Tue Nov 3 08:31:01 2015
New Revision: 290324
URL: https://svnweb.freebsd.org/changeset/base/290324
Log:
MFC r289660,r289664:
Do not allow to execute ptrace(PT_TRACE_ME) when the process is
already traced or when there is no parent which can trace the process.
Modified:
stable/10/sys/kern/sys_process.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/kern/sys_process.c
==============================================================================
--- stable/10/sys/kern/sys_process.c Tue Nov 3 08:28:47 2015 (r290323)
+++ stable/10/sys/kern/sys_process.c Tue Nov 3 08:31:01 2015 (r290324)
@@ -442,7 +442,7 @@ ptrace_vm_entry(struct thread *td, struc
}
#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,
*/
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:
More information about the svn-src-stable-10
mailing list