Re: [PATCH v9 2/3] kernel.h: add to_user_ptr()

From: Gustavo Padovan
Date: Thu Mar 17 2016 - 18:16:43 EST


2016-03-17 Joe Perches <joe@xxxxxxxxxxx>:

> On Thu, 2016-03-17 at 18:19 -0300, Gustavo Padovan wrote:
> > 2016-03-17 Joe Perches <joe@xxxxxxxxxxx>:
> > > On Thu, 2016-03-17 at 16:50 -0400, Rob Clark wrote:
> > > > On Thu, Mar 17, 2016 at 4:40 PM, Joe Perches <joe@xxxxxxxxxxx> wrote:
> > > []
> > > > > It's a name that seems like it should be a straightforward
> > > > > cast of a kernel pointer to a __user pointer like:
> > > > >
> > > > > static inline void __user *to_user_ptr(void *p)
> > > > > {
> > > > > ÂÂÂÂÂÂÂÂreturn (void __user *)p;
> > > > > }
> > > > ahh, ok.ÂÂI guess I was used to using it in the context of ioctl
> > > > structs..ÂÂin that context u64 -> (void __user *) made more sense.
> > > >
> > > > Maybe uapi_to_ptr()?ÂÂ(ok, not super-creative.. maybe someone has a
> > > > better idea)
> > > Maybe u64_to_user_ptr?
> > That is a good name. If everyone agrees I can resend this patch
> > changing it to u64_to_user_ptr. Then should we still keep it on
> > kernel.h?
>
> I've no particular opinion about location,
> but maybe compat.h might be appropriate.

I don't think this is really related to compat. I'd keep kernel.h.

The problem I'm trying to solve here is:

CC drivers/dma-buf/sync_file.o
drivers/dma-buf/sync_file.c: In function âsync_file_ioctl_fence_infoâ:
drivers/dma-buf/sync_file.c:341:19: warning: cast to pointer from
integer of different size [-Wint-to-pointer-cast]
if (copy_to_user((void __user *)info.sync_fence_info, fence_info,

where info.sync_fence_info is __u64.

Gustavo