Re: [PATCH v2 1/2] kernel/sys: add PR_GET_TASK_SIZE option to prctl(2)

From: Cyrill Gorcunov
Date: Thu May 02 2019 - 17:09:52 EST


On Thu, May 02, 2019 at 04:52:21PM -0400, Joel Savitz wrote:
>
> +static int prctl_get_tasksize(void __user * uaddr)
> +{
> + unsigned long task_size = TASK_SIZE;
> + return copy_to_user(uaddr, &task_size, sizeof(unsigned long))
> + ? -EFAULT : 0;
> +}

Won't be possible to use put_user here? Something like

static int prctl_get_tasksize(unsigned long __user *uaddr)
{
return put_user(TASK_SIZE, uaddr) ? -EFAULT : 0;
}