Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Jul 2009 16:39:09 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Tijl Coosemans <tijl@ulyssis.org>
Cc:        Nate Eldredge <neldredge@math.ucsd.edu>, freebsd-hackers@freebsd.org, Alexander Best <alexbestms@math.uni-muenster.de>, Alan Cox <alc@freebsd.org>
Subject:   Re: mmap/munmap with zero length
Message-ID:  <200907131639.10346.jhb@freebsd.org>
In-Reply-To: <200907132133.52217.tijl@ulyssis.org>
References:  <permail-200907050732251e86ffa8000022a8-a_best01@message-id.uni-muenster.de> <200907131428.08923.jhb@freebsd.org> <200907132133.52217.tijl@ulyssis.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907131639.10346.jhb>