Skip to contentSkip to conversation

staging: lusten: conrpc.c: fix different address space sparse warning

PATCH In review Marcos Paulo de Souza 2 participants 5 messages Mar 29, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lusten: conrpc.c: fix different address space sparse warning

head_up parameter is marked with __user attribute, tmp is filled by a copy_from_user from next, that is also marked as __user, so tmp.next needs to be "casted" as __user to make sparse happy.

---

this is mt first patch addressing an issue of sparse, so let me know if I misunderstood the error message

 drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/selftest/conrpc.c +1 -1
index c6a683b..fb7ad74 100644
@@ -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;
Signature · 1 line
2.9.3
maintainer
#1 lore raw
Quoted 3 lines · Marcos Paulo de Souza

head_up parameter is marked with __user attribute, tmp is filled by a copy_from_user from next, that is also marked as __user, so tmp.next needs to be "casted" as __user to make sparse happy.

But is it the correct change?

You also have a typo in your subject :(

Quoted 14 lines

---

this is mt first patch addressing an issue of sparse, so let me know if I misunderstood the error message

 drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/selftest/conrpc.c +0 -0
index c6a683b..fb7ad74 100644

drivers/staging/lustre/lnet/selftest/conrpc.c lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans, · line 490

Quoted 5 lines
drivers/staging/lustre/lnet/selftest/conrpc.c +1 -1
@@ -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)

Aer you sure this is correct? __user changes for lustre is not trivial...

How did you test this?

thanks,

greg k-h

#2 lore raw
Quoted 6 lines · Greg KH
Quoted 3 lines · Marcos Paulo de Souza

head_up parameter is marked with __user attribute, tmp is filled by a copy_from_user from next, that is also marked as __user, so tmp.next needs to be "casted" as __user to make sparse happy.

But is it the correct change?

I don't know, it's my first sparse patch, so I tried to fix this warning.

Quoted 2 lines

You also have a typo in your subject :(

Sorry, didn't noticed yesterday :(

Quoted 18 lines
Quoted 18 lines

---

this is mt first patch addressing an issue of sparse, so let me know if I misunderstood the error message

 drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/selftest/conrpc.c +0 -0
index c6a683b..fb7ad74 100644
@@ -487,7 +487,7 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
 				   sizeof(struct list_head)))
 			return -EFAULT;
 
Quoted 7 lines

drivers/staging/lustre/lnet/selftest/conrpc.c lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans, · line 490

Quoted 2 lines
drivers/staging/lustre/lnet/selftest/conrpc.c +1 -1
-		if (tmp.next == head_up)
+		if ((struct list_head __user *)tmp.next == head_up)

Aer you sure this is correct? __user changes for lustre is not trivial...

How did you test this?

I didn't tested, it just removed the warning. Is this a false positive?

Quoted 4 lines

thanks,

greg k-h

Signature · 2 lines
Thanks,
	Marcos
maintainer
#3 lore raw
Quoted 40 lines · Marcos Paulo de Souza
Quoted 6 lines · Greg KH
Quoted 3 lines · Marcos Paulo de Souza

head_up parameter is marked with __user attribute, tmp is filled by a copy_from_user from next, that is also marked as __user, so tmp.next needs to be "casted" as __user to make sparse happy.

But is it the correct change?

I don't know, it's my first sparse patch, so I tried to fix this warning.

Quoted 2 lines

You also have a typo in your subject :(

Sorry, didn't noticed yesterday :(

Quoted 24 lines
Quoted 15 lines

---

this is mt first patch addressing an issue of sparse, so let me know if I misunderstood the error message

 drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/selftest/conrpc.c +0 -0
index c6a683b..fb7ad74 100644

drivers/staging/lustre/lnet/selftest/conrpc.c lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans, · line 490

Quoted 5 lines
drivers/staging/lustre/lnet/selftest/conrpc.c +1 -1
@@ -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)

Aer you sure this is correct? __user changes for lustre is not trivial...

Quoted 3 lines
Quoted 1 line

How did you test this?

I didn't tested, it just removed the warning. Is this a false positive?

I don't know, it's up to you to prove to me that you know this change is correct. You have to justify your changes, and "because checkpatch.pl complained" isn't a valid justification for something like this :)

thanks,

greg k-h

#4 lore raw
Quoted 41 lines · Greg KH
Quoted 40 lines · Marcos Paulo de Souza
Quoted 6 lines · Greg KH
Quoted 3 lines · Marcos Paulo de Souza

head_up parameter is marked with __user attribute, tmp is filled by a copy_from_user from next, that is also marked as __user, so tmp.next needs to be "casted" as __user to make sparse happy.

But is it the correct change?

I don't know, it's my first sparse patch, so I tried to fix this warning.

Quoted 2 lines

You also have a typo in your subject :(

Sorry, didn't noticed yesterday :(

Quoted 24 lines
Quoted 15 lines

---

this is mt first patch addressing an issue of sparse, so let me know if I misunderstood the error message

 drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/selftest/conrpc.c +0 -0
index c6a683b..fb7ad74 100644

drivers/staging/lustre/lnet/selftest/conrpc.c lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans, · line 490

Quoted 5 lines
drivers/staging/lustre/lnet/selftest/conrpc.c +1 -1
@@ -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)

Aer you sure this is correct? __user changes for lustre is not trivial...

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

How did you test this?

I didn't tested, it just removed the warning. Is this a false positive?

I don't know, it's up to you to prove to me that you know this change is correct. You have to justify your changes, and "because checkpatch.pl complained" isn't a valid justification for something like this :)

Fair enough, I'll take in another sparse report to work on. Thanks!

Quoted 4 lines

thanks,

greg k-h

Signature · 2 lines
Thanks,
	Marcos