From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 17 08:21:48 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 81B09E72 for ; Wed, 17 Apr 2013 08:21:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id F0355302 for ; Wed, 17 Apr 2013 08:21:47 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.6/8.14.6) with ESMTP id r3H8LhMt007492; Wed, 17 Apr 2013 11:21:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.2 kib.kiev.ua r3H8LhMt007492 Received: (from kostik@localhost) by tom.home (8.14.6/8.14.6/Submit) id r3H8LhjT007491; Wed, 17 Apr 2013 11:21:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 17 Apr 2013 11:21:43 +0300 From: Konstantin Belousov To: Carl Shapiro Subject: Re: MADV_FREE and wait4 EFAULT Message-ID: <20130417082143.GW2930@kib.kiev.ua> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JZV+hE4cb0ibQYPB" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: FreeBSD Hackers X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Apr 2013 08:21:48 -0000 --JZV+hE4cb0ibQYPB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 16, 2013 at 02:12:54PM -0700, Carl Shapiro wrote: > I am seeing wait4 system calls failing with an EFAULT and I am trying to > understand what might be going wrong. >=20 > An inspection of the wait4 implementation suggests the opportunity for > EFAULT is within its invocations of copyout. In my situation, the status > and rusage pointer arguments contain addresses to mmaped pages which have > been madvised as MADV_FREE. >=20 > Is it permissible to pass pages which have been madvised MADV_FREE to wai= t4 > or any other system call for that matter? Might there be another > opportunity for a wait4 to EFAULT? Did you ensured with e.g. ktrace and procstat -v that your assumptions hold, i.e. the addresses supplied as wait4(2) arguments are valid ? Please provide the minimal test case demonstrating the behaviour. MADV_FREE should only result in the possible lost of the previous content of the page, not in the faulting of the page access. From the inspection of the code, I do not see how MADV_FREE could result in the memory address becoming invalid. --JZV+hE4cb0ibQYPB Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJRbluXAAoJEJDCuSvBvK1BiCgP/jCSkpdxMFcz6C4FIu5Itihe 6fAlhZ/TyDuxnWvRLAIUI+JiJ3JyxRXgImlixzvMnk3GO9scVaknHooztaLmFtmr UkWceD9zfBNJEtYqEtrKLwKYej2uIj4GUr0Ohh48/jTiqO8t7g3dUMdSxzByXzBp kbP5UOmMBfARb6dFCKkTYW5aUd5Ma8Y9WQhiUdj2iFJBIi2QSi06GMPsAmigtiy+ d4rtAE2B+Ci3qS/R9WEd+AHFKvIvNvZ29S2eXHUIAD1bTaX/ulz2uWrX+p4SQC0M PfGUC+zPML5Btrv8fDfM7T6oompQ7PBjUGi8Dt7pG8fb8R0xMtgwDkNY1VeyJ9uG 468Zot/dcmhVuc9rzWOHRgjjf8rFaDeGIHgDrOo75XYwJHlO42Nzqo2xEWo4ZM2z Cied4/Ra9OvmdrgyXk6jNuPemIvjD+xfNvhAvLasYUQQe0YycBOuiybSGJFaRb60 kF2RPVRQfkzWem63JN30BnvBI5WKeFmmI3WTdjMbHm0lQwEKfF00Pv6bOTjSxvjv uHdD/U/hIKP2TzuXGcb2W35NDjr2QDzbwwrx1lkoS5EoN2PRbvXtdVLqwPqnZqlY gGr4zuEv5k9HhUiHqRL65BUJOpgtY6fk9J+eBxgrK36IMnUq/QEcHm7zEbV1wANl wTnLy1WvvRnyIw+senit =MPJi -----END PGP SIGNATURE----- --JZV+hE4cb0ibQYPB--