From owner-freebsd-amd64@FreeBSD.ORG Fri Mar 21 12:40:01 2014 Return-Path: Delivered-To: freebsd-amd64@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 75011780 for ; Fri, 21 Mar 2014 12:40:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 623412E3 for ; Fri, 21 Mar 2014 12:40:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s2LCe1IY028478 for ; Fri, 21 Mar 2014 12:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s2LCe195028477; Fri, 21 Mar 2014 12:40:01 GMT (envelope-from gnats) Date: Fri, 21 Mar 2014 12:40:01 GMT Message-Id: <201403211240.s2LCe195028477@freefall.freebsd.org> To: freebsd-amd64@FreeBSD.org Cc: From: Konstantin Belousov Subject: Re: amd64/187808: Pointer validation gone missing for __vdso_gettimeofday() X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: Konstantin Belousov List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Mar 2014 12:40:01 -0000 The following reply was made to PR amd64/187808; it has been noted by GNATS. From: Konstantin Belousov To: Peter Holm Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: amd64/187808: Pointer validation gone missing for __vdso_gettimeofday() Date: Fri, 21 Mar 2014 14:30:44 +0200 --dUqh8vgUBVXHzm9w Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 21, 2014 at 09:26:26AM +0000, Peter Holm wrote: >=20 > >Number: 187808 > >Category: amd64 > >Synopsis: Pointer validation gone missing for __vdso_gettimeofday() > >Confidential: no > >Severity: non-critical > >Priority: low > >Responsible: freebsd-amd64 > >State: open > >Quarter: =20 > >Keywords: =20 > >Date-Required: > >Class: sw-bug > >Submitter-Id: current-users > >Arrival-Date: Fri Mar 21 09:30:00 UTC 2014 > >Closed-Date: > >Last-Modified: > >Originator: Peter Holm > >Release: HEAD > >Organization: > >Environment: > FreeBSD t2.osted.lan 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r263418M: Thu M= ar 20 07:20:51 CET 2014 pho@t2.osted.lan:/usr/src/sys/amd64/compile/PHO= amd64 > >Description: > If first argument to gettimeofday() is an invalid pointer the call does n= ot return EFAULT. > >How-To-Repeat: > $ cat -n gettimeofday.c > 1 #include > 2 #include > 3 #include > 4 #include > 5 #include > 6 > 7 int > 8 main(void) > 9 { > 10 if (syscall(SYS_gettimeofday, (void *)-1, NULL) =3D=3D -1) > 11 warn("syscall()"); > 12 > 13 /* broken by r237434 */ > 14 if (gettimeofday((void *)-1, NULL) =3D=3D -1) > 15 warn("gettimeofday()"); > 16 > 17 return (0); > 18 } > $ cc -o gettimeofday -Wall -Wextra -O2 -g gettimeofday.c > $ ./gettimeofday =20 > gettimeofday: syscall(): Bad address > Segmentation fault (core dumped) > $=20 Nothing in the SUSvX requires the pointer to the struct timeval to be validated, or rather, if pointer is not valid, the behaviour is undefined. It is impossible to 'fix' this in reliable manner for userspace function. The expectations are the same as for other functions, e.g. strcmp(3). --dUqh8vgUBVXHzm9w Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJTLDDzAAoJEJDCuSvBvK1BUokP/0VZKbQUO8c53XTIn7W7+VWH MGqD4/F/ylbH5S7MpRasMcw+ARDAyfQ44gdu7EqK8XOcL90l5BXQejZ/D+8s6X5I lRyp2IwPQvIEdHSTDKdooJOAF16hdNEc27VFjC2EulnH2t3s1zD2ksYqcCGukdGp lZ20wLKXWbZuDpXcIK4hVXFl/MwTwMUIUR9sAdk6cueWlm94EqQ63oe/Nh75jaTS sTAd7R/UwLmTJ9rqIvMP1ak/KWrK1UWYAZxkc5uR8prR37ANKo2yKOaowoYoMsJ4 0noiIl+srjGQUGCVjJTEEN06hMZLcyw5eiGN6sYRjnpTwF69bbiMmq1Sv0QYEvGn vQa7R/i1QKyREy+1iNeMIPSJBca1Dbe5OX9rd/8Q1x1hICZcmo7PtGWXEbFFbpNk AZCSNiZ4P9zZUNrLqGka4NhcpbimesUSvFw0JCpmMK6UhN1CM+7M9AL6cTDP8QpN oE6aR6IiRgnTm5PaAhn9CewX6numTUJNhJ7HZ8pcAPkuFJmrjnkpD/9TIK2dT2bH LQmiHMq+iqh4XeJQR1l4mPwfUv5h9jclrT7rElzQ/oDkqvdHIi1U5DBEeho4czns OiT0hJQ7aXx3k7K0M/gb27D4ruSZ+mByn1aSmKTqfmrp0Z8vnc1/JIXFj6MprfCB k9heks5TRXsGAZNKzU2+ =F5Z4 -----END PGP SIGNATURE----- --dUqh8vgUBVXHzm9w--