CS FundamentalsVery hardGATE CS

A system uses paging with a 2-bit protection field (read, write) in each PTE and the CPU also has an execute-disable bit. Which page setting best implements W^X for a JIT compiler that must write code and then run it?

  1. A. Keep the page writable and executable all the time
  2. B. Make the page executable only and write through a file
  3. C. Map the page writable and non-executable while generating code, then change it to read-only executable before running it
  4. D. Disable paging during code generation

Correct answer: C. Map the page writable and non-executable while generating code, then change it to read-only executable before running it

W^X means no page is both writable and executable at once, so a memory-corruption bug cannot inject and run code. JITs flip permissions (or use two mappings of the same frame).

More Operating Systems questions

Exams that ask this topic