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
This commit is contained in:
Konstantin Belousov 2015-10-20 20:22:57 +00:00
parent 16a5c008cc
commit 77b9bec37b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=289660

View file

@ -744,7 +744,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: