Re: [RFC PATCH 02/43] ptrace: cleanup ptrace_request()

From: Arnd Bergmann
Date: Fri Aug 27 2010 - 10:23:35 EST


On Friday 27 August 2010, Namhyung Kim wrote:
> @@ -579,19 +580,19 @@ int ptrace_request(struct task_struct *child, long request,
> ret = ptrace_setoptions(child, data);
> break;
> case PTRACE_GETEVENTMSG:
> - ret = put_user(child->ptrace_message, (unsigned long __user *) data);
> + ret = copy_to_user(datap, &child->ptrace_message,
> + sizeof (child->ptrace_message)) ?
> + -EFAULT : 0;
> break;
>
> case PTRACE_GETSIGINFO:
> ret = ptrace_getsiginfo(child, &siginfo);
> if (!ret)
> - ret = copy_siginfo_to_user((siginfo_t __user *) data,
> - &siginfo);
> + ret = copy_siginfo_to_user(datap, &siginfo);
> break;

If you introduce two pointers, 'siginfo_t __user *usiginfo' and
'unsigned long __user *datap' instead of just 'datap', you can use
get_user/put_user everywhere, which would make the code better readable
and faster.

Otherwise this change looks good.

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