(no subject)

Clayton Weaver (cgweav@eskimo.com)
Mon, 19 Oct 1998 14:41:08 -0700 (PDT)


Re: bug in write(2) system call.

>Hmm. The POSIX description of EFAULT is:

>>[EFAULT]: Bad address
>> The system detected an invalid address in attempting to use
>> an argument of a call. The reliable detection of this error
>> is implementation defined; however, implementations that do
>> detect this condition shall use this value.

This SysV errno value seems unnecessarily ambiguous. One would presume
that EFAULT would be reserved for kernel internal use and EINVAL would be
returned to user space when the page fault cannot be resolved by the
kernel (it's not a swap, cache, or discarded page EFAULT, it's really an
invalid address request).

Just because Posix supports the old SysV silliness doesn't mean we can't
set the more accurate errno value from within functions like write(2) that
also support EINVAL in the Posix and Single Unix Spec standards.

>The man page write.2 says:

>>ERRORS
>> EBADF fd is not a valid file descriptor or is not open
>> for writing.

>> EINVAL fd is attached to an object which is unsuitable for
>> writing.

>> EFAULT buf is outside your accessible address space.

The standard should change this to EINVAL. That's what it is, an invalid
value passed to the kernel. The fact that he kernel page faults on the way
to finding that out should be invisible from user space.

>>It is a matter of quality of implementation.
>>A high quality implementation detects all bad addresses and
>>returns EFAULT for them.

>>Andries

It should return EINVAL for them (imho). Portable code tests for both
of course, but why can't we set errno to the more sensible value?

Regards, Clayton Weaver cgweav@eskimo.com (Seattle)

-
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/