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)
Jan 1 2024, 12:19 PM
Unknown Object (File)
Dec 20 2023, 1:40 AM
Unknown Object (File)
Sep 29 2023, 5:40 PM
Unknown Object (File)
Aug 2 2023, 3:51 AM
Unknown Object (File)
Aug 2 2023, 3:50 AM
Unknown Object (File)
Aug 2 2023, 3:44 AM
Unknown Object (File)
Aug 2 2023, 3:42 AM
Unknown Object (File)
Aug 2 2023, 3:36 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.