From 7ad6f9595cbcf236a4829d6a8e63cc8f592f21ec Mon Sep 17 00:00:00 2001 From: Ken Sato Date: Thu, 1 Mar 2018 09:37:12 +0900 Subject: [PATCH] fix: bug for ptrace_attach self pid --- kernel/syscall.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/syscall.c b/kernel/syscall.c index 3c1e6da2..fee627f1 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -6088,6 +6088,13 @@ static int ptrace_attach(int pid) error = -ESRCH; goto out; } + + if (proc->pid == pid) { + thread_unlock(thread, &lock); + error = -EPERM; + goto out; + } + child = thread->proc; dkprintf("ptrace_attach(): pid requested:%d, thread->tid:%d, thread->proc->pid=%d, thread->proc->parent=%p\n", pid, thread->tid, thread->proc->pid, thread->proc->parent);