From owner-svn-src-head@FreeBSD.ORG Sat Aug 29 20:56:04 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A3701065673; Sat, 29 Aug 2009 20:56:04 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (mail.cs.rice.edu [128.42.1.31]) by mx1.freebsd.org (Postfix) with ESMTP id 71AEF8FC0A; Sat, 29 Aug 2009 20:56:04 +0000 (UTC) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id DB5332C2B32; Sat, 29 Aug 2009 15:35:25 -0500 (CDT) X-Virus-Scanned: by amavis-2.4.0 at mail.cs.rice.edu Received: from mail.cs.rice.edu ([127.0.0.1]) by mail.cs.rice.edu (mail.cs.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Me299NyGGjgA; Sat, 29 Aug 2009 15:35:18 -0500 (CDT) Received: from adsl-216-63-78-18.dsl.hstntx.swbell.net (adsl-216-63-78-18.dsl.hstntx.swbell.net [216.63.78.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.rice.edu (Postfix) with ESMTP id D42B22C2B0E; Sat, 29 Aug 2009 15:35:17 -0500 (CDT) Message-ID: <4A999104.9030809@cs.rice.edu> Date: Sat, 29 Aug 2009 15:35:16 -0500 From: Alan Cox User-Agent: Thunderbird 2.0.0.23 (X11/20090822) MIME-Version: 1.0 To: John Baldwin References: <200908260330.n7Q3U61l047845@svn.freebsd.org> <200908260734.12893.jhb@freebsd.org> In-Reply-To: <200908260734.12893.jhb@freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Colin Percival Subject: Re: svn commit: r196558 - head/usr.bin/look X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2009 20:56:04 -0000 John Baldwin wrote: > On Tuesday 25 August 2009 11:30:06 pm Colin Percival wrote: > >> Author: cperciva >> Date: Wed Aug 26 03:30:06 2009 >> New Revision: 196558 >> URL: http://svn.freebsd.org/changeset/base/196558 >> >> Log: >> Don't try to mmap the contents of empty files. This behaviour was harmless >> prior to r195693, since historical behaviour of mmap(2) was to silently >> ignore length-zero mmap requests; but mmap now returns EINVAL, which caused >> look(1) to emit an error message and fail. >> > > FWIW, it did not silently ignore the request. Instead it rounded the size up > to a page and mapped a page of data. However, if you then passed that pointer > with a length of 0 to munmap() munmap() would fail. > > I don't believe that your claim is correct; round_page(0) == 0. Thus, the value of "size" that would be passed to vm_mmap() would be 0, which would cause it to immediately return "0", indicating success. In this case, I believe that the virtual address that would be returned by mmap(2) would always be the "hint address" for where it should start looking for free space, which would be the end of the heap/data segment, unless the application specified its own hint. In short, and the reason why I'm correcting you here, is to make clear that we needn't worry about earlier versions of FreeBSD that don't implement this change "leaking" or wasting memory from misuse of mmap(2) in this way. Alan