|
|
|
|
|
by koverstreet
3091 days ago
|
|
self modifying code (which exists) would take a massive performance hit. any time a page is marked +X, the kernel would have to mark it -W, and then on page fault the kernel would have to check if userspace was changing something to a clflush instruction. oh, and x86 has variable length instructions - the same byte stream can decode as different instructions depending on where you start - so i doubt it's possible at all on x86 without a massive performance hit (you'd have to keep track of every jump instruction in the entire address space...) |
|
The best approach is to evict all user space pages from cache when an invalid page access happens if the page fault was caused by the software trying to read/write kernel space pages.
Massive performance hit but only to misbehaved software. Normal software will not have the performance hit of the current solution.
Kernel could even switch to unmapped kernel pages solution if too many read/write attempts.