How to randomly remap the kernel?
Posted: Wed Aug 08, 2018 2:30 am
I understand how to identity map the kernel - just map the physical addresses of the kernel code to the same virtual addresses in your page tables and then set cr3 to these page tables and everything works.
My question is, how do you remap the kernel code to a different (potentially random) place in virtual memory? If you change the virtual address, the next instruction after the page table is updated will immediately seg fault as the instruction pointer is invalid. It seems impossible to change the virtual address of the kernel code.
In this case, must you copy the kernel byte code to some different physical address and then map the original address of the kernel as a virtual address to this new physical address? Basically you can only randomize the physical location of the kernel in ram. What are the advantages/disadvantages of doing this?
My question is, how do you remap the kernel code to a different (potentially random) place in virtual memory? If you change the virtual address, the next instruction after the page table is updated will immediately seg fault as the instruction pointer is invalid. It seems impossible to change the virtual address of the kernel code.
In this case, must you copy the kernel byte code to some different physical address and then map the original address of the kernel as a virtual address to this new physical address? Basically you can only randomize the physical location of the kernel in ram. What are the advantages/disadvantages of doing this?