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)
Feb 19 2024, 1:56 PM
Unknown Object (File)
Dec 23 2023, 1:44 AM
Unknown Object (File)
Dec 22 2023, 10:14 AM
Unknown Object (File)
Dec 14 2023, 6:35 PM
Unknown Object (File)
Dec 10 2023, 12:24 AM
Unknown Object (File)
Nov 11 2023, 12:08 PM
Unknown Object (File)
Nov 6 2023, 7:12 PM
Unknown Object (File)
Oct 5 2023, 6:26 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
Lint Skipped
Unit
Tests Skipped

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).