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

From: Cyrill Gorcunov
Date: Fri May 03 2019 - 04:32:20 EST


On Thu, May 02, 2019 at 05:46:08PM -0400, Joel Savitz wrote:
> > 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;
> > }
>
> What would be the benefit of using put_user() over copy_to_user() in
> this context?

It is a common pattern to use put_user with native types, where
copy_to_user more biased for composed types transfer.