问题
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?
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.
回答1:
- 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)
- Profit?
Have fun :)
来源:https://stackoverflow.com/questions/12623066/implementing-linux-system-call-using-lkm