public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse•de>
To: Timur Tabi <timur@freescale•com>
Cc: linuxppc-dev@ozlabs•org
Subject: Re: Confused about usercopy_64.c
Date: Mon, 10 Mar 2008 17:53:31 +0100	[thread overview]
Message-ID: <jeabl6ikqc.fsf@sykes.suse.de> (raw)
In-Reply-To: <47D56419.6000704@freescale.com> (Timur Tabi's message of "Mon\, 10 Mar 2008 11\:38\:49 -0500")

Timur Tabi <timur@freescale•com> writes:

> I'm confused about something in usercopy_64.c:
>
> unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
> {
> 	if (likely(access_ok(VERIFY_READ, from, n)))
> 		n = __copy_from_user(to, from, n);
> 	else
> 		memset(to, 0, n);
> 	return n;
> }
>
> If access_ok() returns false, then that means that we cannot copy the data from
> user-space.  So why are we returning 'n'?

To tell the caller that the function failed.  The result is the number
of bytes _left_ to be copying, ie. zero means success.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse•de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

      parent reply	other threads:[~2008-03-10 16:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-10 16:38 Confused about usercopy_64.c Timur Tabi
2008-03-10 16:50 ` Olof Johansson
2008-03-10 16:53 ` Andreas Schwab [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=jeabl6ikqc.fsf@sykes.suse.de \
    --to=schwab@suse$(echo .)de \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    --cc=timur@freescale$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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