Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Oct 2015 20:22:57 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289660 - head/sys/kern
Message-ID:  <201510202022.t9KKMvxO060296@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510202022.t9KKMvxO060296>