X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=kernel%2Fptrace.c;h=78119a7ebc94c1bfd5fe86ec69ca02ceac4d76e6;hb=9464c7cf61b9433057924c36e6e02f303a00e768;hp=80e780e50351ea8f478be4ef6aea608ecc2f4210;hpb=41689045f6a3cbe0550e1d34e9cc20d2e8c432ba;p=linux-2.6.git diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 80e780e50..78119a7eb 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include @@ -29,7 +29,7 @@ * * Must be called with the tasklist lock write-held. */ -void __ptrace_link(struct task_struct *child, struct task_struct *new_parent) +void __ptrace_link(task_t *child, task_t *new_parent) { BUG_ON(!list_empty(&child->ptrace_list)); if (child->parent == new_parent) @@ -47,7 +47,7 @@ void __ptrace_link(struct task_struct *child, struct task_struct *new_parent) * TASK_TRACED, resume it now. * Requires that irqs be disabled. */ -void ptrace_untrace(struct task_struct *child) +void ptrace_untrace(task_t *child) { spin_lock(&child->sighand->siglock); if (child->state == TASK_TRACED) { @@ -66,7 +66,7 @@ void ptrace_untrace(struct task_struct *child) * * Must be called with the tasklist lock write-held. */ -void __ptrace_unlink(struct task_struct *child) +void __ptrace_unlink(task_t *child) { BUG_ON(!child->ptrace); @@ -117,18 +117,8 @@ int ptrace_check_attach(struct task_struct *child, int kill) int __ptrace_may_attach(struct task_struct *task) { - /* May we inspect the given task? - * This check is used both for attaching with ptrace - * and for allowing access to sensitive information in /proc. - * - * ptrace_attach denies several cases that /proc allows - * because setting up the necessary parent/child relationship - * or halting the specified task is impossible. - */ - int dumpable = 0; - /* Don't let security modules deny introspection */ - if (task == current) - return 0; + if (!task->mm) + return -EPERM; if (((current->uid != task->euid) || (current->uid != task->suid) || (current->uid != task->uid) || @@ -137,9 +127,7 @@ int __ptrace_may_attach(struct task_struct *task) (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE)) return -EPERM; smp_rmb(); - if (task->mm) - dumpable = task->mm->dumpable; - if (!dumpable && !capable(CAP_SYS_PTRACE)) + if (!task->mm->dumpable && !capable(CAP_SYS_PTRACE)) return -EPERM; return security_ptrace(current, task); @@ -185,8 +173,6 @@ repeat: goto repeat; } - if (!task->mm) - goto bad; /* the same process cannot be attached many times */ if (task->ptrace & PT_PTRACED) goto bad; @@ -211,7 +197,7 @@ out: return retval; } -static inline void __ptrace_detach(struct task_struct *child, unsigned int data) +void __ptrace_detach(struct task_struct *child, unsigned int data) { child->exit_code = data; /* .. re-parent .. */ @@ -230,7 +216,6 @@ int ptrace_detach(struct task_struct *child, unsigned int data) ptrace_disable(child); write_lock_irq(&tasklist_lock); - /* protect against de_thread()->release_task() */ if (child->ptrace) __ptrace_detach(child, data); write_unlock_irq(&tasklist_lock);