提交 5861bbfc 编写于 作者: R Roland McGrath

tracehook: fix CLONE_PTRACE

In the change in commit 09a05394, I
overlooked two nits in the logic and this broke using CLONE_PTRACE
when PTRACE_O_TRACE* are not being used.

A parent that is itself traced at all but not using PTRACE_O_TRACE*,
using CLONE_PTRACE would have its new child fail to be traced.

A parent that is not itself traced at all that uses CLONE_PTRACE
(which should be a no-op in this case) would confuse the bookkeeping
and lead to a crash at exit time.

This restores the missing checks and fixes both failure modes.
Reported-by: NEduardo Habkost <ehabkost@redhat.com>
Signed-off-by: NRoland McGrath <roland@redhat.com>
上级 685d87f7
......@@ -172,7 +172,7 @@ static inline void ptrace_init_task(struct task_struct *child, bool ptrace)
child->ptrace = 0;
if (unlikely(ptrace)) {
child->ptrace = current->ptrace;
__ptrace_link(child, current->parent);
ptrace_link(child, current->parent);
}
}
......
......@@ -280,7 +280,7 @@ static inline void tracehook_report_clone(int trace, struct pt_regs *regs,
unsigned long clone_flags,
pid_t pid, struct task_struct *child)
{
if (unlikely(trace)) {
if (unlikely(trace) || unlikely(clone_flags & CLONE_PTRACE)) {
/*
* The child starts up with an immediate SIGSTOP.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册