I've got a user-mode process and kernel module. Now I want to read certain regions of usermode process from kernel, but there's one catch: no copying of usermode memory and simple access by VA. So what we have: task_struct for target process, other related structs (like mm_struct, vma_struct) and virtual address like 0x0070abcd that I want to read or rather map somehow to my kernel module.
I can get page list using get_user_pages for desired memory regions, but what next? Should I map pages somehow into kernel and then try to read them as continuous memory region or there are better solutions?
mm/memory.c, at the implementation ofaccess_process_vm.copy_from_user_pageseems to be a simplememcpy()most of the time, some arch/platform implementations appear to handle D/I cache first. I'd recommend caution unless you know that you're running on x86 or similar.Robert Love, the author ofLinux Kernel Development: quora.com/Linux-Kernel-How-does-copy_to_user-work