gettimeofday((void *)-1, NULL) implicates core dump on recent FreeBSD 11-CURRENT

Peter Jeremy peter at rulingia.com
Wed Jul 8 22:27:52 UTC 2015


On 2015-Jul-08 12:22:03 -0700, Garrett Cooper <yaneurabeya at gmail.com> wrote:
>On Jul 8, 2015, at 12:17, Doug Rabson <dfr at rabson.org> wrote:
>
>> As far as I can tell, POSIX doesn't require either EFAULT or any other
>> behaviour - the text in http://www.open-std.org/jtc1/sc22/open/n4217.pdf
>> just says, "No errors are defined". Our man page is wrong and any real
>> program which relies on gettimeofday not faulting when given bad inputs is
>> broken.
>
>I would suggest the following:
>1. Document behavior in NOTES about gettimeofday returning EFAULT with the specific scenarios kib mentioned, segfaulting otherwise (wordsmithing the actual info of course). Otherwise, it might confuse people who look at the manpage later.

I would suggest adding a comment to intro(2) noting that not all functions
listed in section 2 are necessarily system calls and may report error
conditions (or maybe "perform argument validation") differently when
implemented in userland.

Note that the issues with gettimeofday() also apply to clock_gettime().

I'm not sure if we want to explicitly document the conditions under which
gettimeofday() (or clock_gettime()) are implemented in userland vs syscalls
because that is guaranteed to get stale over time.  How about stating that
these functions are implemented as syscalls only if the AT_TIMEKEEP value
reported by "procstat -x" is NULL.

-- 
Peter Jeremy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 949 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20150709/07ec356b/attachment.bin>


More information about the freebsd-current mailing list