Re: -EFAULT on invalid pointer

Chris Wedgwood (chris@cybernet.co.nz)
Tue, 20 Oct 1998 17:08:02 +1300


On Tue, Oct 20, 1998 at 05:59:58AM +0200, MOLNAR Ingo wrote:

> 2.0 is definitely consistent. (or should be)

buf = malloc(8192+4095) & -4095; /* two pages */

mprotect(&buf[4096],4096,PROT_NONE); /* second page no good */

read(fd,buf,8192);

under 2.0.x, this will ALWAYS fail.

under 2.1.x - this will never fail, it reads either the entire file
if its less than 4k or the first 4k - advancing the file pointer.

> ? we have not changed any semantics.

see above. (the details might not be exact, I have code to show this
though, I'll dig it up if you want)

> this is what i'm talking about. If the driver is buggy and doesnt
> return -EFAULT then user-space has no chance to catch the fault on
> the PROT_NONE.

drivers should return EFAULT if memory is bogus - and we can require
that because we can decide how the OS <-> driver interface should
look.

We cannot so easily defined how userspace code reacts to passing bad
pointers though.

-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.tux.org/lkml/