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)
Sat, Nov 23, 3:57 AM
Unknown Object (File)
Tue, Oct 29, 10:32 AM
Unknown Object (File)
Oct 26 2024, 8:52 AM
Unknown Object (File)
Oct 26 2024, 8:52 AM
Unknown Object (File)
Oct 26 2024, 8:52 AM
Unknown Object (File)
Oct 26 2024, 8:38 AM
Unknown Object (File)
Sep 23 2024, 3:39 AM
Unknown Object (File)
Sep 18 2024, 5:17 PM
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 Not Applicable
Unit
Tests Not Applicable

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.