* [PATCH][CAN]: Fix copy_from_user() results interpretation.
@ 2008-04-25 12:42 Pavel Emelyanov
2008-04-25 14:22 ` Oliver Hartkopp
0 siblings, 1 reply; 15+ messages in thread
From: Pavel Emelyanov @ 2008-04-25 12:42 UTC (permalink / raw)
To: David Miller, urs.thuermann, oliver.hartkopp
Cc: socketcan-core, Linux Netdev List
Sorry for the noise, I had to check this right after facing this problem
with the copy_to_user()...
Both copy_to_ and _from_user return the number of bytes, that failed to
reach their destination, not the 0/-EXXX values.
Other net/ code handles this correctly.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
diff --git a/net/can/raw.c b/net/can/raw.c
index ead50c7..2be8c6e 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -438,12 +438,12 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
err = copy_from_user(filter, optval, optlen);
if (err) {
kfree(filter);
- return err;
+ return -EFAULT;
}
} else if (count == 1) {
err = copy_from_user(&sfilter, optval, optlen);
if (err)
- return err;
+ return -EFAULT;
}
lock_sock(sk);
@@ -495,7 +495,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
err = copy_from_user(&err_mask, optval, optlen);
if (err)
- return err;
+ return -EFAULT;
err_mask &= CAN_ERR_MASK;
@@ -531,7 +531,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (optlen != sizeof(ro->loopback))
return -EINVAL;
- err = copy_from_user(&ro->loopback, optval, optlen);
+ err = copy_from_user(&ro->loopback, optval, optlen) ?
+ -EFAULT : 0;
break;
@@ -539,7 +540,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (optlen != sizeof(ro->recv_own_msgs))
return -EINVAL;
- err = copy_from_user(&ro->recv_own_msgs, optval, optlen);
+ err = copy_from_user(&ro->recv_own_msgs, optval, optlen) ?
+ -EFAULT : 0;
break;
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.
2008-04-25 12:42 [PATCH][CAN]: Fix copy_from_user() results interpretation Pavel Emelyanov
@ 2008-04-25 14:22 ` Oliver Hartkopp
2008-04-26 6:19 ` Wolfgang Grandegger
0 siblings, 1 reply; 15+ messages in thread
From: Oliver Hartkopp @ 2008-04-25 14:22 UTC (permalink / raw)
To: Pavel Emelyanov
Cc: David Miller, Thuermann, Urs, Dr. (K-EFFI/I), socketcan-core,
Linux Netdev List
Pavel Emelyanov wrote:
>
> Sorry for the noise, I had to check this right after facing this problem
> with the copy_to_user()...
>
> Both copy_to_ and _from_user return the number of bytes, that failed to
> reach their destination, not the 0/-EXXX values.
>
> Other net/ code handles this correctly.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
>
Thanks very much for catching this, Pavel!
Acked-by: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
> ---
>
> diff --git a/net/can/raw.c b/net/can/raw.c
> index ead50c7..2be8c6e 100644
> --- a/net/can/raw.c
> +++ b/net/can/raw.c
> @@ -438,12 +438,12 @@ static int raw_setsockopt(struct socket *sock,
> int level, int optname,
> err = copy_from_user(filter, optval, optlen);
> if (err) {
> kfree(filter);
> - return err;
> + return -EFAULT;
> }
> } else if (count == 1) {
> err = copy_from_user(&sfilter, optval, optlen);
> if (err)
> - return err;
> + return -EFAULT;
> }
>
> lock_sock(sk);
> @@ -495,7 +495,7 @@ static int raw_setsockopt(struct socket *sock, int
> level, int optname,
>
> err = copy_from_user(&err_mask, optval, optlen);
> if (err)
> - return err;
> + return -EFAULT;
>
> err_mask &= CAN_ERR_MASK;
>
> @@ -531,7 +531,8 @@ static int raw_setsockopt(struct socket *sock, int
> level, int optname,
> if (optlen != sizeof(ro->loopback))
> return -EINVAL;
>
> - err = copy_from_user(&ro->loopback, optval, optlen);
> + err = copy_from_user(&ro->loopback, optval, optlen) ?
> + -EFAULT : 0;
>
> break;
>
> @@ -539,7 +540,8 @@ static int raw_setsockopt(struct socket *sock, int
> level, int optname,
> if (optlen != sizeof(ro->recv_own_msgs))
> return -EINVAL;
>
> - err = copy_from_user(&ro->recv_own_msgs, optval, optlen);
> + err = copy_from_user(&ro->recv_own_msgs, optval,
> optlen) ?
> + -EFAULT : 0;
>
> break;
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.
2008-04-25 14:22 ` Oliver Hartkopp
@ 2008-04-26 6:19 ` Wolfgang Grandegger
2008-04-26 6:23 ` David Miller
2008-04-26 6:40 ` Sam Ravnborg
0 siblings, 2 replies; 15+ messages in thread
From: Wolfgang Grandegger @ 2008-04-26 6:19 UTC (permalink / raw)
To: Oliver Hartkopp
Cc: Pavel Emelyanov, socketcan-core, Linux Netdev List, David Miller,
Thuermann, Urs, Dr. (K-EFFI/I)
Oliver Hartkopp wrote:
> Pavel Emelyanov wrote:
>> Sorry for the noise, I had to check this right after facing this problem
>> with the copy_to_user()...
>>
>> Both copy_to_ and _from_user return the number of bytes, that failed to
>> reach their destination, not the 0/-EXXX values.
>>
>> Other net/ code handles this correctly.
>>
>> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
>>
>
> Thanks very much for catching this, Pavel!
>
> Acked-by: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
>
>> ---
>>
>> diff --git a/net/can/raw.c b/net/can/raw.c
>> index ead50c7..2be8c6e 100644
>> --- a/net/can/raw.c
>> +++ b/net/can/raw.c
>> @@ -438,12 +438,12 @@ static int raw_setsockopt(struct socket *sock,
>> int level, int optname,
>> err = copy_from_user(filter, optval, optlen);
>> if (err) {
>> kfree(filter);
>> - return err;
>> + return -EFAULT;
>> }
>> } else if (count == 1) {
>> err = copy_from_user(&sfilter, optval, optlen);
>> if (err)
>> - return err;
>> + return -EFAULT;
>> }
>>
>> lock_sock(sk);
>> @@ -495,7 +495,7 @@ static int raw_setsockopt(struct socket *sock, int
>> level, int optname,
>>
>> err = copy_from_user(&err_mask, optval, optlen);
>> if (err)
>> - return err;
>> + return -EFAULT;
>>
>> err_mask &= CAN_ERR_MASK;
>>
>> @@ -531,7 +531,8 @@ static int raw_setsockopt(struct socket *sock, int
>> level, int optname,
>> if (optlen != sizeof(ro->loopback))
>> return -EINVAL;
>>
>> - err = copy_from_user(&ro->loopback, optval, optlen);
>> + err = copy_from_user(&ro->loopback, optval, optlen) ?
>> + -EFAULT : 0;
>>
>> break;
>>
>> @@ -539,7 +540,8 @@ static int raw_setsockopt(struct socket *sock, int
>> level, int optname,
>> if (optlen != sizeof(ro->recv_own_msgs))
>> return -EINVAL;
>>
>> - err = copy_from_user(&ro->recv_own_msgs, optval, optlen);
>> + err = copy_from_user(&ro->recv_own_msgs, optval,
>> optlen) ?
>> + -EFAULT : 0;
>>
>> break;
>>
>>
What about removing the assignment "err =" in that case. It's confusing
otherwise and maybe the variable err is even obsolete.
Wolfgang.
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.
2008-04-26 6:19 ` Wolfgang Grandegger
@ 2008-04-26 6:23 ` David Miller
2008-04-26 6:35 ` Wolfgang Grandegger
2008-04-26 6:40 ` Sam Ravnborg
1 sibling, 1 reply; 15+ messages in thread
From: David Miller @ 2008-04-26 6:23 UTC (permalink / raw)
To: wg; +Cc: oliver.hartkopp, xemul, socketcan-core, netdev, urs.thuermann
From: Wolfgang Grandegger <wg@grandegger.com>
Date: Sat, 26 Apr 2008 08:19:31 +0200
> What about removing the assignment "err =" in that case. It's confusing
> otherwise and maybe the variable err is even obsolete.
Sure, but when fixing a bug it's better to have a completely
localized change like this.
Not something which restructures the code unnecessarily at
the same time, that make it so much harder to review and
validate.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.
2008-04-26 6:23 ` David Miller
@ 2008-04-26 6:35 ` Wolfgang Grandegger
0 siblings, 0 replies; 15+ messages in thread
From: Wolfgang Grandegger @ 2008-04-26 6:35 UTC (permalink / raw)
To: David Miller
Cc: oliver.hartkopp, xemul, socketcan-core, netdev, urs.thuermann
David Miller wrote:
> From: Wolfgang Grandegger <wg@grandegger.com>
> Date: Sat, 26 Apr 2008 08:19:31 +0200
>
>> What about removing the assignment "err =" in that case. It's confusing
>> otherwise and maybe the variable err is even obsolete.
>
> Sure, but when fixing a bug it's better to have a completely
> localized change like this.
>
> Not something which restructures the code unnecessarily at
> the same time, that make it so much harder to review and
> validate.
Well, really,
if (func(x))
return -EFAULT;
instead of
err = func(x);
if (err)
return -EFAULT;
is more straight forward and less confusing and I do not understand, why
it should be harder to review.
Wolfgang.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.
2008-04-26 6:19 ` Wolfgang Grandegger
2008-04-26 6:23 ` David Miller
@ 2008-04-26 6:40 ` Sam Ravnborg
2008-04-26 7:03 ` David Miller
2008-04-26 8:26 ` Oliver Hartkopp
1 sibling, 2 replies; 15+ messages in thread
From: Sam Ravnborg @ 2008-04-26 6:40 UTC (permalink / raw)
To: Wolfgang Grandegger
Cc: Oliver Hartkopp, socketcan-core, Linux Netdev List,
Thuermann, Urs, Dr. (K-EFFI/I), David Miller, Pavel Emelyanov
On Sat, Apr 26, 2008 at 08:19:31AM +0200, Wolfgang Grandegger wrote:
> What about removing the assignment "err =" in that case.
Preferred.
See sample patch below (made on top of -linus
so it does likely not apply but made it only to
see the difference anyway).
Sam
diffstat:
net/can/raw.c | 21 ++++++++++-----------
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/net/can/raw.c b/net/can/raw.c
index 201cbfc..69877b8 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -435,15 +435,13 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (!filter)
return -ENOMEM;
- err = copy_from_user(filter, optval, optlen);
- if (err) {
+ if (copy_from_user(filter, optval, optlen)) {
kfree(filter);
- return err;
+ return -EFAULT;
}
} else if (count == 1) {
- err = copy_from_user(&sfilter, optval, optlen);
- if (err)
- return err;
+ if (copy_from_user(&sfilter, optval, optlen))
+ return -EFAULT;
}
lock_sock(sk);
@@ -493,9 +491,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (optlen != sizeof(err_mask))
return -EINVAL;
- err = copy_from_user(&err_mask, optval, optlen);
- if (err)
- return err;
+ if (copy_from_user(&err_mask, optval, optlen))
+ return -EFAULT;
err_mask &= CAN_ERR_MASK;
@@ -531,7 +528,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (optlen != sizeof(ro->loopback))
return -EINVAL;
- err = copy_from_user(&ro->loopback, optval, optlen);
+ if (copy_from_user(&ro->loopback, optval, optlen))
+ return -EFAULT;
break;
@@ -539,7 +537,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (optlen != sizeof(ro->recv_own_msgs))
return -EINVAL;
- err = copy_from_user(&ro->recv_own_msgs, optval, optlen);
+ if (copy_from_user(&ro->recv_own_msgs, optval, optlen))
+ return -EFAULT;
break;
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.
2008-04-26 6:40 ` Sam Ravnborg
@ 2008-04-26 7:03 ` David Miller
2008-04-26 13:04 ` Wolfgang Grandegger
2008-04-26 8:26 ` Oliver Hartkopp
1 sibling, 1 reply; 15+ messages in thread
From: David Miller @ 2008-04-26 7:03 UTC (permalink / raw)
To: sam; +Cc: wg, oliver.hartkopp, socketcan-core, netdev, urs.thuermann, xemul
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 26 Apr 2008 08:40:07 +0200
> On Sat, Apr 26, 2008 at 08:19:31AM +0200, Wolfgang Grandegger wrote:
> > What about removing the assignment "err =" in that case.
> Preferred.
>
> See sample patch below (made on top of -linus
> so it does likely not apply but made it only to
> see the difference anyway).
I want to make one comment, directed at Wolfgang.
You are absolutely wrong, Wolfgang, in saying that Pavel's
original patch isn't easier to review than just changing
this code to go:
if (copy_*_user())
return -EFAULT;
In fact, recoding things like this is an immense extra hardship on a
reviewer. I'll explain why.
If I see a patch that changes:
err = SOMETHING;
break;
into:
err = SOMETHING_ELSE;
break;
I know, WITH JUST READING THE PATCH, exactly what the side effects of
this change are.
I DO NOT need to bring the code into my editor and validate side
effects to the surrounding code.
I know that the assignment to 'err' is being changed, and that's it.
Whereas if you change:
err = SOMETHING;
break;
into:
if (SOMETHING)
return -SOME_ERROR;
break;
I now have to bring the code into an editor and make sure that the
control flow change doesn't break things.
For example, maybe the exit of the switch statement was important, to
make sure cleanup code runs at the end of the function to release
locks, free allocated memory, etc.
With Pavel's patch it is not necessary to make such validations so
it's INFINITELY easier to validate.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.
2008-04-26 7:03 ` David Miller
@ 2008-04-26 13:04 ` Wolfgang Grandegger
0 siblings, 0 replies; 15+ messages in thread
From: Wolfgang Grandegger @ 2008-04-26 13:04 UTC (permalink / raw)
To: David Miller
Cc: sam, oliver.hartkopp, socketcan-core, netdev, urs.thuermann,
xemul
David Miller wrote:
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Sat, 26 Apr 2008 08:40:07 +0200
>
>> On Sat, Apr 26, 2008 at 08:19:31AM +0200, Wolfgang Grandegger wrote:
>>> What about removing the assignment "err =" in that case.
>> Preferred.
>>
>> See sample patch below (made on top of -linus
>> so it does likely not apply but made it only to
>> see the difference anyway).
>
> I want to make one comment, directed at Wolfgang.
>
> You are absolutely wrong, Wolfgang, in saying that Pavel's
> original patch isn't easier to review than just changing
> this code to go:
>
> if (copy_*_user())
> return -EFAULT;
>
> In fact, recoding things like this is an immense extra hardship on a
> reviewer. I'll explain why.
>
> If I see a patch that changes:
>
> err = SOMETHING;
> break;
>
> into:
>
> err = SOMETHING_ELSE;
> break;
>
> I know, WITH JUST READING THE PATCH, exactly what the side effects of
> this change are.
>
> I DO NOT need to bring the code into my editor and validate side
> effects to the surrounding code.
>
> I know that the assignment to 'err' is being changed, and that's it.
>
> Whereas if you change:
>
> err = SOMETHING;
> break;
>
> into:
>
> if (SOMETHING)
> return -SOME_ERROR;
> break;
>
> I now have to bring the code into an editor and make sure that the
> control flow change doesn't break things.
>
> For example, maybe the exit of the switch statement was important, to
> make sure cleanup code runs at the end of the function to release
> locks, free allocated memory, etc.
>
> With Pavel's patch it is not necessary to make such validations so
> it's INFINITELY easier to validate.
OK, I see, if you have to review a lot of patches, it does matter, indeed.
Wolfgang.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.
2008-04-26 6:40 ` Sam Ravnborg
2008-04-26 7:03 ` David Miller
@ 2008-04-26 8:26 ` Oliver Hartkopp
2008-04-26 9:10 ` David Miller
1 sibling, 1 reply; 15+ messages in thread
From: Oliver Hartkopp @ 2008-04-26 8:26 UTC (permalink / raw)
To: Sam Ravnborg, David Miller
Cc: Wolfgang Grandegger, Thuermann, Urs, Dr. (K-EFFI/I),
Linux Netdev List, socketcan-core, Oliver Hartkopp,
Pavel Emelyanov
Sam Ravnborg wrote:
> On Sat, Apr 26, 2008 at 08:19:31AM +0200, Wolfgang Grandegger wrote:
>
>> What about removing the assignment "err =" in that case.
>>
> Preferred.
>
> See sample patch below (made on top of -linus
> so it does likely not apply but made it only to
> see the difference anyway).
>
I can definitely follow Daves remarks regarding the ability to review
local bugfixes. In this case two commits should be used.
Btw. the cleanup an removal of the err variable usage in the pointed
cases is a good suggestion. So even when the two latest changes in Sam's
patch are not that obvious to be able to be reviewed locally i would
like to ack this patch.
It should apply fine on Linus' tree and the current net-2.6.
Thanks to all of you & have a nice weekend.
Oliver
Acked-by: Oliver Hartkopp <oliver@hartkopp.net>
> diffstat:
> net/can/raw.c | 21 ++++++++++-----------
> 2 files changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/net/can/raw.c b/net/can/raw.c
> index 201cbfc..69877b8 100644
> --- a/net/can/raw.c
> +++ b/net/can/raw.c
> @@ -435,15 +435,13 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
> if (!filter)
> return -ENOMEM;
>
> - err = copy_from_user(filter, optval, optlen);
> - if (err) {
> + if (copy_from_user(filter, optval, optlen)) {
> kfree(filter);
> - return err;
> + return -EFAULT;
> }
> } else if (count == 1) {
> - err = copy_from_user(&sfilter, optval, optlen);
> - if (err)
> - return err;
> + if (copy_from_user(&sfilter, optval, optlen))
> + return -EFAULT;
> }
>
> lock_sock(sk);
> @@ -493,9 +491,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
> if (optlen != sizeof(err_mask))
> return -EINVAL;
>
> - err = copy_from_user(&err_mask, optval, optlen);
> - if (err)
> - return err;
> + if (copy_from_user(&err_mask, optval, optlen))
> + return -EFAULT;
>
> err_mask &= CAN_ERR_MASK;
>
> @@ -531,7 +528,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
> if (optlen != sizeof(ro->loopback))
> return -EINVAL;
>
> - err = copy_from_user(&ro->loopback, optval, optlen);
> + if (copy_from_user(&ro->loopback, optval, optlen))
> + return -EFAULT;
>
> break;
>
> @@ -539,7 +537,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
> if (optlen != sizeof(ro->recv_own_msgs))
> return -EINVAL;
>
> - err = copy_from_user(&ro->recv_own_msgs, optval, optlen);
> + if (copy_from_user(&ro->recv_own_msgs, optval, optlen))
> + return -EFAULT;
>
> break;
>
> _______________________________________________
> Socketcan-core mailing list
> Socketcan-core@lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/socketcan-core
>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.
2008-04-26 8:26 ` Oliver Hartkopp
@ 2008-04-26 9:10 ` David Miller
2008-04-26 9:59 ` Sam Ravnborg
0 siblings, 1 reply; 15+ messages in thread
From: David Miller @ 2008-04-26 9:10 UTC (permalink / raw)
To: oliver
Cc: sam, wg, urs.thuermann, netdev, socketcan-core, oliver.hartkopp,
xemul
From: Oliver Hartkopp <oliver@hartkopp.net>
Date: Sat, 26 Apr 2008 10:26:34 +0200
> Btw. the cleanup an removal of the err variable usage in the pointed
> cases is a good suggestion. So even when the two latest changes in Sam's
> patch are not that obvious to be able to be reviewed locally i would
> like to ack this patch.
Right, I also have no problem with Sam's patch at all and plan to
apply it.
Thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH][CAN]: Fix copy_from_user() results interpretation
2008-04-26 9:10 ` David Miller
@ 2008-04-26 9:59 ` Sam Ravnborg
2008-04-26 10:01 ` David Miller
2008-04-27 5:57 ` David Miller
0 siblings, 2 replies; 15+ messages in thread
From: Sam Ravnborg @ 2008-04-26 9:59 UTC (permalink / raw)
To: David Miller
Cc: oliver, wg, urs.thuermann, netdev, socketcan-core,
oliver.hartkopp, xemul
Both copy_to_ and _from_user return the number of bytes, that failed to
reach their destination, not the 0/-EXXX values.
Based on patch from Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
---
Hi David.
> Right, I also have no problem with Sam's patch at all and plan to
> apply it.
OK - here is a proper patch.
Actual patch is the same - I just added a proper changelog.
Sam
diff --git a/net/can/raw.c b/net/can/raw.c
index 201cbfc..69877b8 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -435,15 +435,13 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (!filter)
return -ENOMEM;
- err = copy_from_user(filter, optval, optlen);
- if (err) {
+ if (copy_from_user(filter, optval, optlen)) {
kfree(filter);
- return err;
+ return -EFAULT;
}
} else if (count == 1) {
- err = copy_from_user(&sfilter, optval, optlen);
- if (err)
- return err;
+ if (copy_from_user(&sfilter, optval, optlen))
+ return -EFAULT;
}
lock_sock(sk);
@@ -493,9 +491,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (optlen != sizeof(err_mask))
return -EINVAL;
- err = copy_from_user(&err_mask, optval, optlen);
- if (err)
- return err;
+ if (copy_from_user(&err_mask, optval, optlen))
+ return -EFAULT;
err_mask &= CAN_ERR_MASK;
@@ -531,7 +528,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (optlen != sizeof(ro->loopback))
return -EINVAL;
- err = copy_from_user(&ro->loopback, optval, optlen);
+ if (copy_from_user(&ro->loopback, optval, optlen))
+ return -EFAULT;
break;
@@ -539,7 +537,8 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
if (optlen != sizeof(ro->recv_own_msgs))
return -EINVAL;
- err = copy_from_user(&ro->recv_own_msgs, optval, optlen);
+ if (copy_from_user(&ro->recv_own_msgs, optval, optlen))
+ return -EFAULT;
break;
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 277cfe0..4a7327b 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -105,7 +105,7 @@ endif
# Do section mismatch analysis for each module/built-in.o
ifdef CONFIG_DEBUG_SECTION_MISMATCH
- cmd_secanalysis = ; scripts/mod/modpost $@
+ #cmd_secanalysis = ; scripts/mod/modpost $@
endif
# Compile C sources (.c)
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation
2008-04-26 9:59 ` Sam Ravnborg
@ 2008-04-26 10:01 ` David Miller
2008-04-26 10:05 ` Sam Ravnborg
2008-04-27 5:57 ` David Miller
1 sibling, 1 reply; 15+ messages in thread
From: David Miller @ 2008-04-26 10:01 UTC (permalink / raw)
To: sam
Cc: oliver, wg, urs.thuermann, netdev, socketcan-core,
oliver.hartkopp, xemul
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 26 Apr 2008 11:59:23 +0200
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 277cfe0..4a7327b 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -105,7 +105,7 @@ endif
>
> # Do section mismatch analysis for each module/built-in.o
> ifdef CONFIG_DEBUG_SECTION_MISMATCH
> - cmd_secanalysis = ; scripts/mod/modpost $@
> + #cmd_secanalysis = ; scripts/mod/modpost $@
> endif
>
> # Compile C sources (.c)
What's this? :-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation
2008-04-26 10:01 ` David Miller
@ 2008-04-26 10:05 ` Sam Ravnborg
0 siblings, 0 replies; 15+ messages in thread
From: Sam Ravnborg @ 2008-04-26 10:05 UTC (permalink / raw)
To: David Miller
Cc: oliver, wg, urs.thuermann, netdev, socketcan-core,
oliver.hartkopp, xemul
On Sat, Apr 26, 2008 at 03:01:46AM -0700, David Miller wrote:
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Sat, 26 Apr 2008 11:59:23 +0200
>
> > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > index 277cfe0..4a7327b 100644
> > --- a/scripts/Makefile.build
> > +++ b/scripts/Makefile.build
> > @@ -105,7 +105,7 @@ endif
> >
> > # Do section mismatch analysis for each module/built-in.o
> > ifdef CONFIG_DEBUG_SECTION_MISMATCH
> > - cmd_secanalysis = ; scripts/mod/modpost $@
> > + #cmd_secanalysis = ; scripts/mod/modpost $@
> > endif
> >
> > # Compile C sources (.c)
>
> What's this? :-)
Sorry!
Workaround for a newly introduced kbuild bug and I did
not review my patch properly.
I hand edited it out in first mail but should have
done so in my queued patch to prevent this.
Sam
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH][CAN]: Fix copy_from_user() results interpretation
2008-04-26 9:59 ` Sam Ravnborg
2008-04-26 10:01 ` David Miller
@ 2008-04-27 5:57 ` David Miller
1 sibling, 0 replies; 15+ messages in thread
From: David Miller @ 2008-04-27 5:57 UTC (permalink / raw)
To: sam
Cc: oliver, wg, urs.thuermann, netdev, socketcan-core,
oliver.hartkopp, xemul
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 26 Apr 2008 11:59:23 +0200
> Both copy_to_ and _from_user return the number of bytes, that failed to
> reach their destination, not the 0/-EXXX values.
>
> Based on patch from Pavel Emelyanov <xemul@openvz.org>
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Acked-by: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
Applied, sans the local Makefile.build change in your tree,
thanks Sam. :-)
^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <mailman.2289.1209191345.4974.socketcan-core@lists.berlios.de>]
end of thread, other threads:[~2008-04-27 5:57 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-25 12:42 [PATCH][CAN]: Fix copy_from_user() results interpretation Pavel Emelyanov
2008-04-25 14:22 ` Oliver Hartkopp
2008-04-26 6:19 ` Wolfgang Grandegger
2008-04-26 6:23 ` David Miller
2008-04-26 6:35 ` Wolfgang Grandegger
2008-04-26 6:40 ` Sam Ravnborg
2008-04-26 7:03 ` David Miller
2008-04-26 13:04 ` Wolfgang Grandegger
2008-04-26 8:26 ` Oliver Hartkopp
2008-04-26 9:10 ` David Miller
2008-04-26 9:59 ` Sam Ravnborg
2008-04-26 10:01 ` David Miller
2008-04-26 10:05 ` Sam Ravnborg
2008-04-27 5:57 ` David Miller
[not found] <mailman.2289.1209191345.4974.socketcan-core@lists.berlios.de>
2008-04-26 6:33 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).