Subject: Re: [PATCH net-next 1/5] tipc: silence sparse warnings

From: Ying Xue <[email-masked]>
Date: Fri, 27 Sep 2013 16:01:21 +0800

On 09/27/2013 01:59 PM, David Miller wrote:
> From: Jon Maloy <[email-masked]>
> Date: Tue, 24 Sep 2013 04:27:44 -0500
> 
>> From: Ying Xue <[email-masked]>
>>
>> Eliminate below sparse warnings:
>>
>> net/tipc/link.c:1210:37: warning: cast removes address space of expression
>> net/tipc/link.c:1218:59: warning: incorrect type in argument 2 (different address spaces)
>> net/tipc/link.c:1218:59:    expected void const [noderef] <asn:1>*from
>> net/tipc/link.c:1218:59:    got unsigned char const [usertype] *[assigned] sect_crs
>> net/tipc/msg.c:96:61: warning: incorrect type in argument 3 (different address spaces)
>> net/tipc/msg.c:96:61:    expected void const *from
>> net/tipc/msg.c:96:61:    got void [noderef] <asn:1>*const iov_base
>> net/tipc/socket.c:341:49: warning: Using plain integer as NULL pointer
>> net/tipc/socket.c:1371:36: warning: Using plain integer as NULL pointer
>> net/tipc/socket.c:1694:57: warning: Using plain integer as NULL pointer
>>
>> Signed-off-by: Ying Xue <[email-masked]>
>> Signed-off-by: Andreas Bofjäll <[email-masked]>
>> Reviewed-by: Paul Gortmaker <[email-masked]>
>> Signed-off-by: Jon Maloy <[email-masked]>
> 
> These warnings are not just for fun, and they are certainly not an
> invitation to stick casts all over the place to make them go away.
> 
> They indicate real problems in the TIPC code.
> 
> There really are user pointers in the iovecs here, and that's why the
> iov_base member is annotated with "__user".
> 
> These iovecs carry pointers that come from userspace via socket calls.
> 
> And you absolutely cannot pass user pointers to skb_copy_to_linear_data()
> and friends as they access the source pointer using memcpy().
> 

Good point!
It's better for us to use memcpy_fromiovecend() instead of
skb_copy_to_linear_data() and its friends.

We will submit another version to correct this error soon.

Regards,
Ying

> You have to use the proper interfaces for accessing userspace memory,
> ones that have their arguments annotated with __user.
> 
> I'm not applying this series, sorry.
> 
>