Date: Tue, 7 Jul 2015 18:41:54 -0400 (EDT) From: Garrett Wollman <wollman@hergotha.csail.mit.edu> To: oliver.pinter@hardenedbsd.org Cc: freebsd-current@freebsd.org Subject: Re: gettimeofday((void *)-1, NULL) implicates core dump on recent FreeBSD 11-CURRENT Message-ID: <201507072241.t67MfsX5085860@hergotha.csail.mit.edu> References: <CAPQ4ffuTcN_ytcH7GPY0s6OqWK9qo6MGaVZhOB%2B0ojWfd=fNCg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <CAPQ4ffuTcN_ytcH7GPY0s6OqWK9qo6MGaVZhOB+0ojWfd=fNCg@mail.gmail.com> oliver.pinter@hardenedbsd.org writes: >We discovered that one of the kyua test failing from gettimeofday tests. >The error is reproducible on recent snapshot from 11-CURRENT: >ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/amd64/amd64/ISO-IMAGES/11.0/FreeBSD-11.0-CURRENT-amd64-20150630-r284969-disc1.iso > >root@freebsd:~ # cat test-gtod.c >#include <sys/time.h> >#include <stdio.h> > >int >main(int argc, char **argv) >{ > > return (gettimeofday((void *)-1, NULL)); >} Undefined behavior here, so the implementation is allowed to do literally anything at all. Certainly there's nothing wrong with it dumping core here, and the test is erroneous if it expects otherwise. The first argument to gettimeofday() MUST be a valid pointer to struct timeval, and the implementation does depend on this. Perhaps the test was (erroneously) written to assume that gettimeofday() was a system call, and could therefore detect invalid pointers and return [EFAULT]. This has not been the case for some time. (In HEAD, not since r237434, which is three years ago.) -GAWollman
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507072241.t67MfsX5085860>