public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eli Carter <eli.carter@inet.com>
To: Ben Greear <greearb@candelatech.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: copy_from_user returns a positive value?
Date: Fri, 15 Feb 2002 09:01:54 -0600	[thread overview]
Message-ID: <3C6D22E2.F708A646@inet.com> (raw)
In-Reply-To: <3C6C6E0C.6000309@candelatech.com>

Ben Greear wrote:
> 
> I have an IOCTL defined something like this:
> 
>         _IOWR (0xfe, (30<<3 + 0), __u8 [696])
> 
> I'm really passing in a structure of size 696 (does that matter)?
> 
> When I make the copy from user call:
> 
>        if ((ret = copy_from_user(&reqconf, arg, sizeof(reqconf)))) {
>           printk("ERROR: copy_from_user returned: %i, sizeof(reqconf): %i\n",
>                  ret, sizeof(reqconf));
>           return ret;
>        }
> 
> I see this printed out:
> 
> ERROR: copy_from_user returned: 696, sizeof(reqconf): 696
> 
> According to some docs I saw on the web, it should return 0, or the
> number it has left to copy.  So, why does it have 696 bytes left
> to copy??

Because it couldn't copy any of the data?  The code I have seen
generally returns -EFAULT in that case.
Could you be trying to copy data from somewhere that the user does not
have permission to read? Can you verify that both pointers are valid? 
&reqconf should be in the kernel's memory space and arg should be a
pointer provided by the user-space app pointing to memory in userland.

You might want to get the Linux Device Drivers book... the 2nd ed. is
out.

HTH,

Eli
--------------------. "If it ain't broke now,
Eli Carter           \                  it will be soon." -- crypto-gram
eli.carter(a)inet.com `-------------------------------------------------

  reply	other threads:[~2002-02-15 15:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-15  2:10 copy_from_user returns a positive value? Ben Greear
2002-02-15 15:01 ` Eli Carter [this message]
2002-02-15 23:24 ` David S. 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=3C6D22E2.F708A646@inet.com \
    --to=eli.carter@inet.com \
    --cc=greearb@candelatech.com \
    --cc=linux-kernel@vger.kernel.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