Re: Followup: copy_to_user return value breaks lots of code

Michael Elizabeth Chastain (
Fri, 23 Jan 1998 14:24:54 -0600

Hi Bill and everybody,

> In some cases a 0 might be used as a success indication, so all of the
> case #2 situations may not be errors. But if you have a list of
> occurrences, why not post it so people can check it out.

First I want to be sure of what the return value of copy_to_user is.
Linus has said: 'the number of bytes left _un_copied'. I have checked
kernels back to 2.1.20 and it's been this way for a long time.

I think some code writers got confused because put_user and get_user
return 0 or -EFAULT. But copy_from_user and copy_to_user return
'the number of bytes left _un_copied'. So some of those
case #2 'return copy_to_user(..., ..., ...);' lines are actually bugs
and I will find them and report them.

Meanwhile there is still a bug in __generic_copy_to_user, because it
doesn't follow the contract. I believe in programming by contract.

I would also be happier if __copy_to_user got renamed to something
that didn't start with two underscores, such as copy_to_user_nocheck.
Right now, there is no obvious way to tell which macros in uaccess.h
are strictly internal and which ones are meant to be called. I would
like to see all the internal macros, and *only* the internal macros,
start with two underscores.

Michael Chastain
"love without fear"