2017-06-02 04:08:18

by Dilger, Andreas

[permalink] [raw]
Subject: Re: [lustre-devel] [PATCH] drivers: staging/lustre: conrpc.c - fix sparse error: incompatible types in comparison expression (different address spaces)

On Jun 1, 2017, at 14:56, Tordek <[email protected]> wrote:
> This is fairly minor but it reveals a few hidden warnings, could I get some feedback on it?

This is a known problem, but can't immediately be fixed because it affects the interface with
userspace tools. The correct solution is to not use struct list_head in the user interface
at all, and we are looking into that.

In the meantime, feel free to look at the warnings that are now visible after this patch is
applied (locally on your system).

Thanks, Andreas

>
> On 5 May 2017 10:53, "Tordek" <[email protected]> wrote:
> This patch makes a lot of new warnings pop up, because the error is
> blocking the rest of the file from being processed.
>
> On 5 May 2017 at 10:51, Guillermo O. Freschi <[email protected]> wrote:
>> Signed-off-by: Guillermo O. Freschi <[email protected]>
>> ---
>> drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
>> index da36c55b86d3..f4578200994f 100644
>> --- a/drivers/staging/lustre/lnet/selftest/conrpc.c
>> +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
>> @@ -487,7 +487,7 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
>> sizeof(struct list_head)))
>> return -EFAULT;
>>
>> - if (tmp.next == head_up)
>> + if ((struct list_head __user *)tmp.next == head_up)
>> return 0;
>>
>> next = tmp.next;
>> --
>> 2.11.0
>>
> _______________________________________________
> lustre-devel mailing list
> [email protected]
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation








2017-06-02 05:15:45

by Guillermo O. Freschi

[permalink] [raw]
Subject: Re: [lustre-devel] [PATCH] drivers: staging/lustre: conrpc.c - fix sparse error: incompatible types in comparison expression (different address spaces)

On 02/06/17 01:08, Dilger, Andreas wrote:
> On Jun 1, 2017, at 14:56, Tordek <[email protected]> wrote:
>> This is fairly minor but it reveals a few hidden warnings, could I get some feedback on it?
>
> This is a known problem, but can't immediately be fixed because it affects the interface with
> userspace tools. The correct solution is to not use struct list_head in the user interface
> at all, and we are looking into that.
>
> In the meantime, feel free to look at the warnings that are now visible after this patch is
> applied (locally on your system).

Well, changing

struct lstcon_rpc_ent *ent;

to

struct lstcon_rpc_ent __user *ent;

makes most of the post-patch warnings disappear (and it... makes sense? we're calling `copy_to_user(&ent...` a lot, so I assume ent would be pointing to userspace memory).

But if this is meant to change, maybe it's a moot point to look at it at all.

Thanks!


>
> Thanks, Andreas
>
>>
>> On 5 May 2017 10:53, "Tordek" <[email protected]> wrote:
>> This patch makes a lot of new warnings pop up, because the error is
>> blocking the rest of the file from being processed.
>>
>> On 5 May 2017 at 10:51, Guillermo O. Freschi <[email protected]> wrote:
>>> Signed-off-by: Guillermo O. Freschi <[email protected]>
>>> ---
>>> drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
>>> index da36c55b86d3..f4578200994f 100644
>>> --- a/drivers/staging/lustre/lnet/selftest/conrpc.c
>>> +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
>>> @@ -487,7 +487,7 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
>>> sizeof(struct list_head)))
>>> return -EFAULT;
>>>
>>> - if (tmp.next == head_up)
>>> + if ((struct list_head __user *)tmp.next == head_up)
>>> return 0;
>>>
>>> next = tmp.next;
>>> --
>>> 2.11.0
>>>
>> _______________________________________________
>> lustre-devel mailing list
>> [email protected]
>> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
>
> Cheers, Andreas
> --
> Andreas Dilger
> Lustre Principal Architect
> Intel Corporation
>
>
>
>
>
>
>

--
Tordek

2017-06-07 09:15:30

by Guillermo O. Freschi

[permalink] [raw]
Subject: [PATCH 1/2] drivers: staging/lustre: conrpc.c - fix sparse error: incompatible types in comparison expression (different address spaces)

This patch reveals hidden warnings after this line.

(This is a stepping-stone patch for the following one, it should be
ignored as per Andreas Dilger.)

Signed-off-by: Guillermo O. Freschi <[email protected]>
---
drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index da36c55b86d3..f4578200994f 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -487,7 +487,7 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
sizeof(struct list_head)))
return -EFAULT;

- if (tmp.next == head_up)
+ if ((struct list_head __user *)tmp.next == head_up)
return 0;

next = tmp.next;
--
2.11.0

2017-06-07 09:15:41

by Guillermo O. Freschi

[permalink] [raw]
Subject: [PATCH 2/2] drivers: staging/lustre: conrpc.c - fix sparse warning: warning: incorrect type in argument * (different address spaces)

The calls to `copy_to_user` suggest that `ent` is pointing to userspace
memory, but `ent` is missing the `__user` qualifier.

Signed-off-by: Guillermo O. Freschi <[email protected]>
---
drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index f4578200994f..04a5d7e80151 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -469,7 +469,7 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
{
struct list_head tmp;
struct list_head __user *next;
- struct lstcon_rpc_ent *ent;
+ struct lstcon_rpc_ent __user *ent;
struct srpc_generic_reply *rep;
struct lstcon_rpc *crpc;
struct srpc_msg *msg;
--
2.11.0