Page MenuHomeFreeBSD

Permit private writable mappings of read-only /dev/zero descriptors.
ClosedPublic

Authored by jhb on Aug 6 2015, 2:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 29, 10:32 AM
Unknown Object (File)
Sat, Oct 26, 8:52 AM
Unknown Object (File)
Sat, Oct 26, 8:52 AM
Unknown Object (File)
Sat, Oct 26, 8:52 AM
Unknown Object (File)
Sat, Oct 26, 8:38 AM
Unknown Object (File)
Sep 23 2024, 3:39 AM
Unknown Object (File)
Sep 18 2024, 5:17 PM
Unknown Object (File)
Sep 18 2024, 11:51 AM
Subscribers

Details

Summary

The changes that introduced fo_mmap() treated all character device
mappings as if MAP_SHARED was always present since in general MAP_PRIVATE
is not permitted for character devices. However, there is one exception
in that MAP_PRIVATE mappings are permitted for /dev/zero.

Only require a writable file descriptor (FWRITE) for shared, writable
mappings of character devices. vm_mmap_cdev() will reject any private
mappings for other devices.

Test Plan
  • Open /dev/zero with O_RDONLY and try to map it with PROT_WRITE and MAP_PRIVATE.
  • Verified that a MAP_SHARED mapping with O_RDONLY still fails.

(These tests will end up in tests/sys/vm/mmap_test.c eventually, but
that has some other pending changes and I don't want to hold up this
fix for those.)

Diff Detail

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

Event Timeline

jhb retitled this revision from to Permit private writable mappings of read-only /dev/zero descriptors..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added reviewers: alc, kib, peter.
jhb added a subscriber: sbruno.
kib edited edge metadata.
This revision is now accepted and ready to land.Aug 6 2015, 3:06 PM
This revision was automatically updated to reflect the committed changes.