Reputation: 23268
I was wondering how I would go about copying data from a page of a user process while in kernel mode. I have access to the mm_struct and all the vm_area_structs of the process. In vm_ops I saw the access method but I am unsure of how that works. Any help would be appreciated.
Upvotes: 3
Views: 1928
Reputation: 23268
It can be done via access_process_vm method declared in linux/mm.h (I believe I can't remember at this moment). This is the safe way to access process memory and what is needed is the task_struct of the process, a buffer for the data to be written/read, the size, address within the vm space of the process and whether it is a read/write. The reason this is safe is because it has all the proper locks in place to handle this and has backup methods of obtaining the user space pages if get_user_pages should fail. The return value is the number of bytes read from the vm space.
Upvotes: 2