Page MenuHomeFreeBSD

Add stricter checking of mmap() arguments.
ClosedPublic

Authored by jhb on Aug 29 2014, 9:56 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 16, 11:05 PM
Unknown Object (File)
Sun, Dec 15, 2:24 PM
Unknown Object (File)
Fri, Nov 29, 10:35 PM
Unknown Object (File)
Sun, Nov 24, 11:54 PM
Unknown Object (File)
Sun, Nov 24, 8:34 PM
Unknown Object (File)
Nov 6 2024, 10:48 PM
Unknown Object (File)
Nov 5 2024, 12:53 PM
Unknown Object (File)
Nov 1 2024, 12:04 PM
Subscribers
None

Details

Summary

Add stricter checking of some mmap() arguments:

  • Fail with EINVAL if an invalid protection mask is passed to mmap().
  • Fail with EINVAL if an unknown flag is passed to mmap().
  • Fail with EINVAL if both MAP_PRIVATE and MAP_SHARED are passed to mmap().
  • Require one of either MAP_PRIVATE or MAP_SHARED for non-anonymous mappings.
Test Plan
  • Just trying to boot with the original patch forced me to relax the requirement for at least one of MAP_SHARED or MAP_PRIVATE to not be applied for anonymous mappings because libthr uses MAP_ANON without a sharing mode.
  • I wrote a test program to exercise these various new errors as well as several normal use cases. All of the tests succeed on current HEAD, including the ones that pass invalid flags or protection that this change checks for. With the patch, the latter tests now fail.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

jhb retitled this revision from to Add stricter checking of mmap() arguments..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)

Fixed an issue with prot checking.

jhb added a reviewer: kib.
jhb edited the test plan for this revision. (Show Details)

Make prot an int.

Check for invalid mmap() flags.

jhb updated this revision to Diff 1635.

Closed by commit rS271635 (authored by @jhb).