Date: Sun, 9 Jun 2019 22:34:28 -0500 From: Doug Moore <dougm@rice.edu> To: Doug Moore <dougm@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r348843 - head/sys/vm Message-ID: <a609706d-e996-3350-a62a-d99630dfeab4@rice.edu> In-Reply-To: <201906100307.x5A37BFt099669@repo.freebsd.org> References: <201906100307.x5A37BFt099669@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
I understand that I ought to have included this in the previous checkin. MFC after: 3 days and that my description of the appropriateness of len==0 passed to mmap was imprecise. I regret the error. Doug Moore On 6/9/19 10:07 PM, Doug Moore wrote: > Author: dougm > Date: Mon Jun 10 03:07:10 2019 > New Revision: 348843 > URL: https://svnweb.freebsd.org/changeset/base/348843 > > Log: > There are times when a len==0 parameter to mmap is okay. But on a > 32-bit machine, a len parameter just a few bytes short of 4G, rounded > up to a page boundary and hitting zero then, is not okay. Return > failure in that case. > > Reported by: pho > Reviewed by: alc, kib (mentor) > Tested by: pho > Differential Revision: https://reviews.freebsd.org/D20580 > > Modified: > head/sys/vm/vm_mmap.c > > Modified: head/sys/vm/vm_mmap.c > ============================================================================== > --- head/sys/vm/vm_mmap.c Sun Jun 9 22:55:21 2019 (r348842) > +++ head/sys/vm/vm_mmap.c Mon Jun 10 03:07:10 2019 (r348843) > @@ -257,7 +257,10 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s > > /* Adjust size for rounding (on both ends). */ > size += pageoff; /* low end... */ > - size = (vm_size_t) round_page(size); /* hi end */ > + /* Check for rounding up to zero. */ > + if (round_page(size) < size) > + return (EINVAL); > + size = round_page(size); /* hi end */ > > /* Ensure alignment is at least a page and fits in a pointer. */ > align = flags & MAP_ALIGNMENT_MASK; >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a609706d-e996-3350-a62a-d99630dfeab4>