lkml.org 
[lkml]   [1998]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
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);
read(fd,&buffer,8192);


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.



-cw

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html

\
 
 \ /
  Last update: 2005-03-22 13:44    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site