operating-systempage-tableswriteonly

What is the use of a page table entry being write-only?


I'm currently learning about page tables in my operating systems class, and have come across the read-only bit. I understand the use of having the status of the page table being read-only or being read-write, but in lecture, they also mentioned that you could also have a write-only state. It doesn't make sense to me why a process can't read from a page that it can write to. I tried to look it up online but couldn't find anything about this write-only state.

My question, therefore, is why would a programmer need a page to be write-only? What is an example of such a case?


Solution

  • A program does not want limitation. "He" thinks it is bug-free.

    Protection is mostly a operating system stuff (to catch bugs, to block non-well-intention programs).

    For OS point of view: CPU cache could be optimized differently with write-only pages (from user space preferences, or just by heuristics, and OS will use the flag to check if heuristic assumption were correct). But also paging algorithms could be done differently.

    In user space: for multi-process communication, a process could use a write-only page. A library could use the write-only, to catch some bugs earlier (and not too late with corrupt buffer, and so hard to debug).

    But also a encoder program (reading a large file and saving a encoded file): this will notify OS that pages could be written to disk and discarded from memory.

    But also for security: you write a passphrase on a write-only page, so you should no more care about malicious plugin trying to read the passphrase (other processes are able to read it), so still a multi-process communication case.

    But as you know, pages protection flags do not reflect what program want. They are just internal checks of OS, and they could change. OS could set more restricted flags, and relax them (after tacking action) on first protection hit (e.g. COW [this requires also write-protected])