[lkml]   [1998]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: copy_from_user() fix
On Mon, Aug 24, 1998 at 10:54:24PM +1000, Richard Gooch wrote:

> ??? What's wrong with EFAULT?

Nothing...IMO, but someone was arguing for syscall/function call
transparency, so bogus arguments might be useful at segfaulting for
debugging purposed (personally, I say make gdb hook the syscall
returns and check for EFAULT).

Not long ago in writing some code to check consistency of various
APIs on linux and other unicies I've found that different OSs fail in
different ways - and apparently failures aren't clearly defined.

For example, consider the following pseudo-code (4k pages assumed):

buffer = malloc(8192 + 4095) & -4095;
mprotect(buffer + 4096,4096,PROT_NONE);

/* we now have an 8k buffer - the first 4k is usable, the second is not */

fd = open("some-small-file",O_RDONLY);

Now, linux 2.0.x will return EFAULT, even if the file is less that
4k, and not advance the file pointer.

Linux 2.1.x will advance the file pointer, return EFAULT if the file
is larger than 4k, and if not, it will succeed and return the number
of bytes read.

Other OSs do one or the other, mostly the linux 2.0.x behaviour.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:44    [W:0.110 / U:4.732 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site