From owner-freebsd-hackers@FreeBSD.ORG Tue Jul 14 16:32:45 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8CF711065670; Tue, 14 Jul 2009 16:32:45 +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 60B898FC1A; Tue, 14 Jul 2009 16:32:45 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id 044D62C2A8C; Tue, 14 Jul 2009 11:32:45 -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 HSh1f0KxIBOq; Tue, 14 Jul 2009 11:32:37 -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 216852C2A7E; Tue, 14 Jul 2009 11:32:37 -0500 (CDT) Message-ID: <4A5CB324.80708@cs.rice.edu> Date: Tue, 14 Jul 2009 11:32:36 -0500 From: Alan Cox User-Agent: Thunderbird 2.0.0.22 (X11/20090626) MIME-Version: 1.0 To: John Baldwin References: <200907131428.08923.jhb@freebsd.org> <200907132133.52217.tijl@ulyssis.org> <200907131639.10346.jhb@freebsd.org> In-Reply-To: <200907131639.10346.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Nate Eldredge , Tijl Coosemans , Alexander Best , Alan Cox , freebsd-hackers@freebsd.org Subject: Re: mmap/munmap with zero length X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jul 2009 16:32:45 -0000 John Baldwin wrote: > On Monday 13 July 2009 3:33:51 pm Tijl Coosemans wrote: > >> On Monday 13 July 2009 20:28:08 John Baldwin wrote: >> >>> On Sunday 05 July 2009 3:32:25 am Alexander Best wrote: >>> >>>> so mmap differs from the POSIX recommendation right. the malloc.conf >>>> option seems more like a workaround/hack. imo it's confusing to have >>>> mmap und munmap deal differently with len=0. being able to >>>> succesfully alocate memory which cannot be removed doesn't seem >>>> logical to me. >>>> >>> This should fix it: >>> >>> --- //depot/user/jhb/acpipci/vm/vm_mmap.c >>> +++ /home/jhb/work/p4/acpipci/vm/vm_mmap.c >>> @@ -229,7 +229,7 @@ >>> >>> fp = NULL; >>> /* make sure mapping fits into numeric range etc */ >>> - if ((ssize_t) uap->len < 0 || >>> + if ((ssize_t) uap->len <= 0 || >>> ((flags & MAP_ANON) && uap->fd != -1)) >>> return (EINVAL); >>> >> Why not "uap->len == 0"? Sizes of 2GiB and more (32bit) shouldn't cause >> an error. >> > > I don't actually disagree and know of locally modified versions of FreeBSD > that remove this check for precisely that reason. > > I have no objections to "uap->len == 0" (without the cast). Alan