From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 13 20:05:47 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 2AB96106564A; Mon, 13 Jul 2009 20:05:47 +0000 (UTC) (envelope-from tijl@ulyssis.org) Received: from mailrelay003.isp.belgacom.be (mailrelay003.isp.belgacom.be [195.238.6.53]) by mx1.freebsd.org (Postfix) with ESMTP id 62CDB8FC16; Mon, 13 Jul 2009 20:05:45 +0000 (UTC) (envelope-from tijl@ulyssis.org) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ar0EAH8pW0pR9Sb4/2dsb2JhbACBUc43hAkF Received: from 248.38-245-81.adsl-dyn.isp.belgacom.be (HELO kalimero.kotnet.org) ([81.245.38.248]) by relay.skynet.be with ESMTP; 13 Jul 2009 21:36:23 +0200 Received: from kalimero.kotnet.org (kalimero.kotnet.org [127.0.0.1]) by kalimero.kotnet.org (8.14.3/8.14.3) with ESMTP id n6DJXq0o007739; Mon, 13 Jul 2009 21:33:52 +0200 (CEST) (envelope-from tijl@ulyssis.org) From: Tijl Coosemans To: freebsd-hackers@freebsd.org Date: Mon, 13 Jul 2009 21:33:51 +0200 User-Agent: KMail/1.9.10 References: <200907131428.08923.jhb@freebsd.org> In-Reply-To: <200907131428.08923.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200907132133.52217.tijl@ulyssis.org> Cc: Nate Eldredge , Alan Cox , Alexander Best 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: Mon, 13 Jul 2009 20:05:47 -0000 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.