From: Pavel Emelyanov <xemul@openvz.org>
To: David Miller <davem@davemloft.net>,
urs.thuermann@volkswagen.de, oliver.hartkopp@volkswagen.de
Cc: socketcan-core@lists.berlios.de,
Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH][CAN]: Fix copy_from_user() results interpretation.
Date: Fri, 25 Apr 2008 16:42:14 +0400 [thread overview]
Message-ID: <4811D1A6.909@openvz.org> (raw)
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;
next reply other threads:[~2008-04-25 12:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-25 12:42 Pavel Emelyanov [this message]
2008-04-25 14:22 ` [PATCH][CAN]: Fix copy_from_user() results interpretation 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4811D1A6.909@openvz.org \
--to=xemul@openvz.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=oliver.hartkopp@volkswagen.de \
--cc=socketcan-core@lists.berlios.de \
--cc=urs.thuermann@volkswagen.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.