Author: kib
Date: Tue Oct 20 20:22:57 2015
New Revision: 289660
URL: https://svnweb.freebsd.org/changeset/base/289660

Log:
  Reviewed by:  jhb, pho
  Reported and tested by:       pho
  Sponsored by: The FreeBSD Foundation
  MFC after:    2 weeks
  Differential revision:        https://reviews.freebsd.org/D3908

Modified:
  head/sys/kern/sys_process.c

Modified: head/sys/kern/sys_process.c
==============================================================================
--- head/sys/kern/sys_process.c Tue Oct 20 20:15:25 2015        (r289659)
+++ head/sys/kern/sys_process.c Tue Oct 20 20:22:57 2015        (r289660)
@@ -744,7 +744,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:
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to