Is it necessary to call set_memory_rw after disabling CR0 "Write Protect" to modify read only pages in Linux kernel?

Viewed 168
1 Answers

No.

The CR0.WP method disables write protect support globally, whereas the set_memory_rw method merely adds the write bit to specific pages. If you have already disabled write protection through the control register, then there is no need to do anything else. All kernel memory will be globally writable from within the kernel until you re-enable write protection through the same register.

Make sure you disable interrupts before writing to CR0, then re-enable them afterwards.

Related