Page MenuHomeFreeBSD

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

Authored by dougm on Jun 9 2019, 8:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 23 2024, 5:24 AM
Unknown Object (File)
Nov 16 2024, 6:23 PM
Unknown Object (File)
Oct 31 2024, 11:43 AM
Unknown Object (File)
Oct 30 2024, 12:19 PM
Unknown Object (File)
Oct 23 2024, 6:57 AM
Unknown Object (File)
Oct 12 2024, 2:08 AM
Unknown Object (File)
Oct 3 2024, 3:27 PM
Unknown Object (File)
Sep 23 2024, 7:42 AM
Subscribers

Details

Summary

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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

vm_mmap.c
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 marked an inline comment as done.Jun 9 2019, 8:54 PM
This revision is now accepted and ready to land.Jun 9 2019, 8:59 PM

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.