Patch Linux kernel version 5+ to subvert memory protections

If you’re interested in removing some of the memory protections (especially around RWX) in the Linux kernel version 5+, here are some pointers:

In the arch folder, edit the Kconfig file, and look for config STRICT_KERNEL_RWX and config STRICT_MODULE_RWX. You can change their default value to the values below.

In the init folder, edit the main.c file and search for the line containing

#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)

One option would be to undefine both of them:

Another option is to search for the mark_readonly(void) function, and remove most of its contents:

Afterwards, you can compile the kernel and enjoy modifying structures that were once read-only.