Accessing variable in kernel-space from user-level space

不问归期 提交于 2019-12-06 16:06:12

Userspace cannot see kernel ram directly in any case - and mmap'ing /dev/kmem isn't a good solution either (it is really ugly in my opinion and should only be used for kernel debugging).

I think the nicest way is to expose it either through a file in /proc (which is pretty easy) or a character-device with an IOCTL (which is only slightly more complicated).

(NB: this is Linux / Unix specific)

On most operating systems you cannot access kernel space variables from user space.
You will need to expose your data via the mechanisms that your os provides. This could be a custom system call, a file exposed via the vfs or any other form of IPC.

On Unix this is usually done by mmap-ing some special device file like /dev/kmem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!