I have a kernel module where I need to call mprotect for the current user process. I was thinking of making a direct call to do_mprotect_pkey but the function is marked as static
. If not, is there any other way like going through a system call or something?
Asked
Active
Viewed 189 times
0

ruke
- 55
- 5
-
You should not use mprotect in kernel space, but you can archive the same effects with `set_memory_(ro|rw|x|nx)` in kernel – Chen Li Mar 30 '22 at 14:27
-
actually, I need to use pkey_mprotect, how is it possible with `set_memory_`. Also, could you elaborate on why should I not use mprotect(for user page) in kernel space and if I want, how could I use it? – ruke Mar 30 '22 at 20:32
-
because mprotect is syscall, and you should never call syscall in kernel space. – Chen Li Mar 31 '22 at 01:32
-
@ruke as you can see in the [source code](https://elixir.bootlin.com/linux/latest/source/mm/mprotect.c#L670), pkey_mprotect syscall calls do_mprotect_pkey, maybe use this one? – TomerSamara Apr 07 '22 at 18:33