简体   繁体   English

如何从内核模块扫描用户空间内存

[英]How to scan user-space memory from a kernel module

I want to make a kernel module that scans a user-run process' memory and changes some values. 我想制作一个内核模块,该模块扫描用户运行进程的内存并更改一些值。 I'm having some trouble figuring out the proper way to interface with user-memory. 我在找出与用户内存进行交互的正确方法时遇到了一些麻烦。

I found the copy_to_user and copy_from_user functions from the IBM article User space memory access from the Linux kernel . 我从IBM文章Linux内核中的用户空间内存访问中找到了copy_to_usercopy_from_user函数。 But they take a user-space pointer. 但是它们采用了用户空间指针。 Since I'm not sure where the variable is that I want to change, I would like to scan the memory of the user-process but can't seem to find how. 由于我不确定要在哪里更改变量,因此我想扫描用户进程的内存,但似乎找不到方法。

I was thinking of reading /proc/$(pidof process)/maps for the address since the variable I want to change is in a shared object there. 我正在考虑读取/proc/$(pidof process)/maps地址/proc/$(pidof process)/maps ,因为要更改的变量位于共享对象中。 However, I read online that it's not good practice to read files in from a kernel module. 但是,我在线阅读了从内核模块读取文件的好习惯。

I was also thinking perhaps I could rig the copy_from_user function to copy the entire thing but didn't think that was a good idea since it's really big. 我也在想,也许我可以绑定copy_from_user函数来复制整个内容,但由于它很大,所以认为这不是一个好主意。

Any suggestions would be appreciated. 任何建议,将不胜感激。 Thanks. 谢谢。

What are you scanning the memory for and why can't you just do that from userspace? 您要扫描内存的内容是什么,为什么不能仅从用户空间进行内存扫描呢? This is easily doable with accessing the mem file in proc. 通过在proc中访问mem文件,可以轻松做到这一点。

As for the answer to the question, I'm afraid this is one of the things that if you have a reason to do it, you can easily find out how to do it on your own. 至于问题的答案,恐怕这是如果您有理由这样做的一件事,那么您可以轻松地找到自己的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从内核分配用户空间内存 - allocate user-space memory from kernel 如何从 Linux kernel 空间模块执行/调用用户空间定义的 function? - How can I Execute/Call a user-space defined function from Linux kernel space module? 从用户空间进程启用内核模块调试 - Enable debugging of kernel module from user-space process 执行/调用用户空间程序,并从内核模块获取其pid - Execute/invoke user-space program, and get its pid, from a kernel module 如何在内核模块中获取数组的地址,以便能够在用户空间应用程序中使用它? - How to get the address of an array in kernel module so I'll be able to use it within a user-space application? 从内核空间执行用户空间功能 - Executing a user-space function from the kernel space 在用户空间使用netlink从内核检索数据时出错 - Error in receving data from kernel using netlink at user-space UDP数据包从内核到Linux中用户空间的路径 - Path of the UDP packet from kernel to user-space in Linux 当我们从用户空间调用任何套接字时,内核如何知道要调用哪个驱动程序? - How kernel know which driver to be called when we are calling any socket from user-space? 使用shm_open和mmap将用户空间映射到内核空间内存 - mapping user-space to kernel-space memory using shm_open & mmap
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM