使用LKM实现Linux系统调用 [英] Implementing Linux System Call using LKM

查看:110
本文介绍了使用LKM实现Linux系统调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图向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.

推荐答案

  1. 找到sys_call_table/ia32_sys_call_table
  2. 制作副本并根据需要对其进行修改(将其命名为my_sys_call_table)
  3. 找到 system_call 条目(这个和其他人
  4. 修改NR_syscalls比较指令如果表格大小已更改
  5. sys_call_table参考> system_call 指向my_sys_call_table:

  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)

  • 利润?
  • 玩得开心:)

    这篇关于使用LKM实现Linux系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆