Implementing Linux System Call using LKM

让人想犯罪 __ 提交于 2019-11-27 22:38:33

问题


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:


  1. Locate sys_call_table/ia32_sys_call_table
  2. Make a copy and modify it as you wish (let it be my_sys_call_table)
  3. Locate system_call entry (this one and others)
  4. Modify NR_syscalls compare instruction in case of table size has changed
  5. Modify sys_call_table reference at system_call to point to my_sys_call_table:

    500        call *sys_call_table(,%eax,4)
          ->
    500        call *my_sys_call_table(,%eax,4)
    
  6. Profit?

Have fun :)



来源:https://stackoverflow.com/questions/12623066/implementing-linux-system-call-using-lkm

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