netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
To: Pavel Emelyanov <xemul@openvz.org>
Cc: David Miller <davem@davemloft.net>,
	"Thuermann, Urs, Dr. (K-EFFI/I)" <urs.thuermann@volkswagen.de>,
	socketcan-core@lists.berlios.de,
	Linux Netdev List <netdev@vger.kernel.org>
Subject: Re: [PATCH][CAN]: Fix copy_from_user() results interpretation.
Date: Fri, 25 Apr 2008 16:22:13 +0200	[thread overview]
Message-ID: <4811E915.80303@volkswagen.de> (raw)
In-Reply-To: <4811D1A6.909@openvz.org>

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;
>  
>


  reply	other threads:[~2008-04-25 14:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-25 12:42 [PATCH][CAN]: Fix copy_from_user() results interpretation Pavel Emelyanov
2008-04-25 14:22 ` Oliver Hartkopp [this message]
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=4811E915.80303@volkswagen.de \
    --to=oliver.hartkopp@volkswagen.de \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=socketcan-core@lists.berlios.de \
    --cc=urs.thuermann@volkswagen.de \
    --cc=xemul@openvz.org \
    /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 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).