From: "David S. Miller" <davem@redhat.com>
To: greearb@candelatech.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: copy_from_user returns a positive value?
Date: Fri, 15 Feb 2002 15:24:55 -0800 (PST) [thread overview]
Message-ID: <20020215.152455.85412802.davem@redhat.com> (raw)
In-Reply-To: <3C6C6E0C.6000309@candelatech.com>
In-Reply-To: <3C6C6E0C.6000309@candelatech.com>
From: Ben Greear <greearb@candelatech.com>
Date: Thu, 14 Feb 2002 19:10:20 -0700
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
Either:
1) 'arg' is a bogus userland pointer
or
2) 'arg' is a valid userland pointer, but someone has done a
set_fs(KERNEL_DS) so only kernel pointers are valid for user
copies.
A lot of the "32-bit userland on 64-bit kernel" compatability laters
work by doing #2. They munge the 32-bit user structures into kernel
side copies, and do set_fs(KERNEL_DS) and pass in the pointers to the
kernel copies to the real syscall then finally restore things back to
USER_DS.
copy_{to,from}_user always return, as you correctly noted, the amount
of data that could not be copied or "0" for success. That is why all
code does something like this:
err = 0;
if (copy_{to,from}_user(...))
err = -EFAULT;
I don't know where some people get the idea that copy_{to,from}_user
should return -EFAULT on failure. Maybe some port is buggy :-)
prev parent reply other threads:[~2002-02-15 23:27 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
2002-02-15 23:24 ` David S. Miller [this message]
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=20020215.152455.85412802.davem@redhat.com \
--to=davem@redhat.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