I'm writing a kernel module that needs to change page permissions for a task. Normally, the task would just call mprotect and set the permissions. As I understand Linux kernel has sys_mprotect
, which performs the actual system call.
Is it possible that my Linux kernel module calls sys_mprotect
? I cannot seem to find a kernel API that allows that.
I figured out it's possible to call sys_mprotect
in a kernel module as explained here using kallsyms_lookup_name
.
An alternative way for achieving some of the page permission changes is to directly call kernel APIs such as pte_wrprotect
, which will clear the write permissions from a PTE.