Commit 24011a7e authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

Support mmap with MAP_PRIVATE when non-writable pages are requested

Summary: We have the ability to support this rather odd combination of flags, so do it.

Reviewed By: yfeldblum

Differential Revision: D13067516

fbshipit-source-id: b0006a995ef614253440820e029f66288b557c37
parent 592dcbca
...@@ -95,7 +95,11 @@ void* mmap(void* addr, size_t length, int prot, int flags, int fd, off_t off) { ...@@ -95,7 +95,11 @@ void* mmap(void* addr, size_t length, int prot, int flags, int fd, off_t off) {
return MAP_FAILED; return MAP_FAILED;
} }
// No private copy on write. // No private copy on write.
if ((flags & MAP_PRIVATE) == MAP_PRIVATE && fd != -1) { // If the map isn't writable, we can let it go through as
// whether changes to the underlying file are reflected in the map
// is defined to be unspecified by the standard.
if ((flags & MAP_PRIVATE) == MAP_PRIVATE &&
(prot & PROT_WRITE) == PROT_WRITE && fd != -1) {
return MAP_FAILED; return MAP_FAILED;
} }
// Map isn't anon, must be file backed. // Map isn't anon, must be file backed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment