使用LKM实现Linux系统调用 [英] Implementing Linux System Call using LKM
问题描述
我试图向Linux内核3.2.x添加新的系统调用. 在Internet上搜索有用的参考资料时,我有一个印象,就是无法像将SO一样
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屋!