summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-10-20 20:22:57 +0000
committerkib <kib@FreeBSD.org>2015-10-20 20:22:57 +0000
commit791509a17bcfb081804f8a309a69f1ebdb511731 (patch)
treed6ac59d637b5d3cb16e3bdaa175011387d59ef31 /sys/kern
parentc197d1a9f750051ae14c18eccbe64db5d75a1d03 (diff)
downloadFreeBSD-src-791509a17bcfb081804f8a309a69f1ebdb511731.zip
FreeBSD-src-791509a17bcfb081804f8a309a69f1ebdb511731.tar.gz
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
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/sys_process.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index 588b43c..85be385 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -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:
OpenPOWER on IntegriCloud