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)
Feb 28 2024, 10:49 AM
Unknown Object (File)
Feb 28 2024, 9:03 AM
Unknown Object (File)
Feb 27 2024, 3:17 AM
Unknown Object (File)
Feb 4 2024, 2:44 AM
Unknown Object (File)
Dec 26 2023, 4:14 PM
Unknown Object (File)
Dec 20 2023, 12:10 AM
Unknown Object (File)
Nov 9 2023, 9:01 PM
Unknown Object (File)
Oct 8 2023, 7:57 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.