Direct available kernel user memory on Linux

I have a user mode process and a kernel module. Now I want to read some areas of the usermode process from the kernel, but there is one possibility: do not copy usermode memory and simple VA access. So, we have: task_struct for the target process, other related structures (for example, mm_struct, vma_struct) and a virtual address, such as 0x0070abcd, which I want to read or, rather, somehow map to my kernel module.

I can get a list of pages using get_user_pages for the desired memory areas, but what next? Should I somehow map pages to the kernel and then try to read them as a continuous memory area, or are there better solutions?

+4
source share
1 answer

The problem is that β€œsearching” in user space requires blocking a ton of material. So it’s better if you make a short copy than leave everything locked for an arbitrary time. Your user process cannot be mapped to the VM in the current processor. In fact, it can be completely replaced with a disk, run on another processor, in the middle of its own kernel call, etc.

Linux kernel: copy_from_user - pointer structure

+1
source

All Articles