I am writing a kernel module that is to be called by process p1 to overwrite a data page that belongs to a target process p2.
First, inside the kernel module and while responding to a write event to proc file system issued by p1. I used the process id of the target process (p2) to search for the latter's task struct (p2_task).
To search for the particular page I used get_user_pages()
, obviously calling it on (p2_task->mm
). I then called kmap()
on the page returned by the previous function. Once I got the pointer I used the typical memory functions (memset()
) to write to that memory. Finally called kunmap()
.
However, once the process starts running again I can see that what I did had no effect on the target process p2.
I am not sure what I did wrong. Can anyone help?
I suspect that somehow you can not write to memory belongs to process p2 while responding to a request coming from p2. Since here we are in a different context.
Is this true, if not what else I can check. If it is the problem, is there anyways I can get around that?