-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Currently, our mprotect is quite limited. It returns EACCES for non-anonymous file mappings and, as of #74, it also returns EACCES when applied in part to an anonymous mapping. Both limitations have the same root: we already use page protection flags for our own management so messing with them beyond it will break it.
For example, the page committed bit is used in all mappings to implement lazy page memory allocation on first access. The page write bit is used as a trigger to catch writes to non-anonymous mappings in order to write dirty pages to the underlying files.
As for anonymous mappings, we used to support partial mprotect on them but it showed bugs as #74 demonstrates so it had to be disabled. In short, the reason is that our internal mmap representation only keeps track of mmap-level protection flags for the whole region, not for individual pages. We could add a map of per-page protection flags but this needs some redesign of internal structures and it's better to be done globally, taking other needs into account (like supporting mprotect for non-anonymous mappings). This is what this ticket is about.