lkml.org 
[lkml]   [2005]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH consolidate sys_ptrace
Date
On Tue, 01 Nov 2005 06:12:21 +0100, Christoph Hellwig wrote:

<snip>

> Index: linux-2.6/kernel/ptrace.c
> ===================================================================
> --- linux-2.6.orig/kernel/ptrace.c 2005-10-31 13:15:52.000000000 +0100
> +++ linux-2.6/kernel/ptrace.c 2005-10-31 17:30:43.000000000 +0100
> @@ -406,3 +406,85 @@
>
> return ret;
> }
> +
> +#ifndef __ARCH_SYS_PTRACE
> +static int ptrace_get_task_struct(long request, long pid,
> + struct task_struct **childp)
> +{
> + struct task_struct *child;
> + int ret;
This "ret" is basically unused and should go away

> +
> + /*
> + * Callers use child == NULL as an indication to exit early even
> + * when the return value is 0, so make sure it is non-NULL here.
> + */
> + *childp = NULL;
> +
> + if (request == PTRACE_TRACEME) {
> + /*
> + * Are we already being traced?
> + */
> + if (current->ptrace & PT_PTRACED)
> + return -EPERM;
> + ret = security_ptrace(current->parent, current);
> + if (ret)
if (security_ptrace(current->parent, current))

> + return -EPERM;
> + /*
> + * Set the ptrace bit in the process ptrace flags.
> + */
> + current->ptrace |= PT_PTRACED;
> + return 0;
> + }
> +
> + /*
> + * You may not mess with init
> + */
> + if (pid == 1)
> + return -EPERM;
> +
> + ret = -ESRCH;
Not needed (anymore)

> + read_lock(&tasklist_lock);
> + child = find_task_by_pid(pid);
> + if (child)
> + get_task_struct(child);
> + read_unlock(&tasklist_lock);
> + if (!child)
> + return -ESRCH;
> +
> + *childp = child;
> + return 0;
> +}
> +


Best,
Norbert


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-11-01 11:13    [W:0.919 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site