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

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

问题描述

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

推荐答案

  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天全站免登陆