使用 LKM 实现 Linux 系统调用 [英] Implementing Linux System Call using LKM
问题描述
我试图向 linux 内核 3.2.x 添加一个新的系统调用.在互联网上搜索有用的参考资料时,我的印象是不可能像在 SO 问题中那样将系统调用实现为可加载模块 是否可以通过 LKM 添加系统调用?
I was trying to add a new System Call to linux kernel 3.2.x. While searching for useful reference material over the internet i had an impression that implementing system call as a loadable module is not possible as in SO question Is it possible to add a system call via a LKM?
我找到了另一个链接,上面写着有一种方法可以添加系统调用,而无需使用模块作为包装器重新编译内核,但这超出了本文档的范围".来源 http://hekimian-williams.com/?p=20
I found another link which says this "There is a way to add system calls without recompiling the kernel using modules as a wrapper, but that is beyond the scope of this document". source http://hekimian-williams.com/?p=20
我知道静态实现系统调用将需要我每次进行任何更改时编译内核代码.有没有上面提到的博客中指定的方法可以将其实现为模块.
I know implementing system call statically will require me to compile the kernel code each time i make any changes. Is there a way as specified in the above mentioned blog that i can implement it as a module.
非常感谢任何有关方向的建议或指示.
Any suggestions or pointers in the direction are much appreciated.
推荐答案
- 找到
sys_call_table/ia32_sys_call_table
- 制作一个副本并根据需要进行修改(让它成为
my_sys_call_table
) - 找到system_call 条目(这个和其他人)
- 修改
NR_syscalls
比较指示 表大小发生变化时 修改
sys_call_table
参考在 system_call 指向my_sys_call_table
:
- Locate
sys_call_table/ia32_sys_call_table
- Make a copy and modify it as you wish (let it be
my_sys_call_table
) - Locate system_call entry (this one and others)
- Modify
NR_syscalls
compare instruction in case of table size has changed Modify
sys_call_table
reference at system_call to point tomy_sys_call_table
:
500 call *sys_call_table(,%eax,4)
->
500 call *my_sys_call_table(,%eax,4)
玩得开心:)
这篇关于使用 LKM 实现 Linux 系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!