From owner-freebsd-current@freebsd.org Tue Jul 7 22:41:57 2015 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D823C9968E2 for ; Tue, 7 Jul 2015 22:41:57 +0000 (UTC) (envelope-from wollman@hergotha.csail.mit.edu) Received: from hergotha.csail.mit.edu (wollman-1-pt.tunnel.tserv4.nyc4.ipv6.he.net [IPv6:2001:470:1f06:ccb::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BBD7109B for ; Tue, 7 Jul 2015 22:41:57 +0000 (UTC) (envelope-from wollman@hergotha.csail.mit.edu) Received: from hergotha.csail.mit.edu (localhost [127.0.0.1]) by hergotha.csail.mit.edu (8.14.9/8.14.9) with ESMTP id t67MfsOj085861; Tue, 7 Jul 2015 18:41:54 -0400 (EDT) (envelope-from wollman@hergotha.csail.mit.edu) Received: (from wollman@localhost) by hergotha.csail.mit.edu (8.14.9/8.14.4/Submit) id t67MfsX5085860; Tue, 7 Jul 2015 18:41:54 -0400 (EDT) (envelope-from wollman) Date: Tue, 7 Jul 2015 18:41:54 -0400 (EDT) From: Garrett Wollman Message-Id: <201507072241.t67MfsX5085860@hergotha.csail.mit.edu> To: oliver.pinter@hardenedbsd.org Subject: Re: gettimeofday((void *)-1, NULL) implicates core dump on recent FreeBSD 11-CURRENT References: Organization: none Cc: freebsd-current@freebsd.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (hergotha.csail.mit.edu [127.0.0.1]); Tue, 07 Jul 2015 18:41:54 -0400 (EDT) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on hergotha.csail.mit.edu X-Mailman-Approved-At: Tue, 07 Jul 2015 23:01:15 +0000 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jul 2015 22:41:57 -0000 In article 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 >#include > >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