Last active
July 17, 2023 07:57
-
-
Save CaledoniaProject/d48f5d65d9a334f702a485a0391b271e to your computer and use it in GitHub Desktop.
Disable write protection on Linux kernel >= 5.3.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://medium.com/@hadfiabdelmoumene/change-value-of-wp-bit-in-cr0-when-cr0-is-panned-45a12c7e8411 | |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0) | |
inline void write_cr0_new(unsigned long cr0) | |
{ | |
asm volatile("mov %0,%%cr0" : "+r"(cr0), "+m"(__force_order)); | |
} | |
#else | |
#define write_cr0_new write_cr0 | |
#endif | |
#define WPOFF do { write_cr0_new(read_cr0() & (~0x10000)); } while (0); | |
#define WPON do { write_cr0_new(read_cr0() | 0x10000); } while (0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment