Page MenuHomeFreeBSD

Make mmap fail when len parameter, round up to page size, becomes zero

Authored by dougm on Jun 9 2019, 8:31 PM.



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.

Test Plan

Peter Holm reported this problem, and reported that this change resolved it.

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

dougm created this revision.Jun 9 2019, 8:31 PM
dougm added a reviewer: markj.Jun 9 2019, 8:34 PM
kib added inline comments.Jun 9 2019, 8:45 PM
261 ↗(On Diff #58457)

Why do you need the cast ? size already has size_t type, and vm_size_t is effectively an alias to it.
And if cast is needed, there should be no space after ')'.

dougm updated this revision to Diff 58458.Jun 9 2019, 8:54 PM

Drop needless casts.

dougm marked an inline comment as done.Jun 9 2019, 8:54 PM
kib accepted this revision.Jun 9 2019, 8:59 PM
This revision is now accepted and ready to land.Jun 9 2019, 8:59 PM
alc accepted this revision.Jun 10 2019, 3:03 AM

I think that it is likely that other, related system calls exhibit a similar misbehavior.

This revision was automatically updated to reflect the committed changes.