From owner-svn-src-all@FreeBSD.ORG Mon Aug 31 12:25:50 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E73B1065692; Mon, 31 Aug 2009 12:25:50 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id D2C718FC18; Mon, 31 Aug 2009 12:25:49 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 8303746B29; Mon, 31 Aug 2009 08:25:49 -0400 (EDT) Received: from jhbbsd.hudson-trading.com (unknown [209.249.190.8]) by bigwig.baldwin.cx (Postfix) with ESMTPA id DC3D78A02E; Mon, 31 Aug 2009 08:25:48 -0400 (EDT) From: John Baldwin To: Alan Cox Date: Mon, 31 Aug 2009 08:25:13 -0400 User-Agent: KMail/1.9.7 References: <200908260330.n7Q3U61l047845@svn.freebsd.org> <200908260734.12893.jhb@freebsd.org> <4A999104.9030809@cs.rice.edu> In-Reply-To: <4A999104.9030809@cs.rice.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200908310825.14372.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 31 Aug 2009 08:25:48 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.3 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx 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-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 12:25:50 -0000 On Saturday 29 August 2009 4:35:16 pm Alan Cox wrote: > 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. Yes, I think you are correct. -- John Baldwin