Re: [PATCH 2/3 RESEND] ptrace: cleanup address space conversion on ptrace_request()

Christoph Hellwig
2010-08-23T16:21:08Z

On Tue, Aug 24, 2010 at 01:06:15AM +0900, Namhyung Kim wrote:
> In some cases 'data' should be considered as a user pointer but it requires
> cast with additional __force markup which was missing. Rather than add the
> markups wherever needed, make use of a temporary variable of user pointer.
> This patch is based on compat_ptrace_request() implementation.
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
> ---
> kernel/ptrace.c | 13 +++++++------
> 1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/ptrace.c b/kernel/ptrace.c
> index 4afd9b8..7547b1c 100644
> --- a/kernel/ptrace.c
> +++ b/kernel/ptrace.c
> @@ -564,6 +564,7 @@ int ptrace_request(struct task_struct *child, long request,
> {
> int ret = -EIO;
> siginfo_t siginfo;
> + unsigned long __user *datap = (unsigned long __user __force *) data;

Just make this a

void __user *datap = (void __user *)data;

and you can pass it around withjout additional casts. Also no need
for the force here I think.

You'll still need a cast for the put_user calls, or you could just
convert them to copy_to_user which is fine with a void pointer.