免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
1234
最近访问板块 发新帖
楼主: superhappy1
打印 上一主题 下一主题

Linux内核的代码段是只读的吗?进程的代码段呢? [复制链接]

论坛徽章:
0
31 [报告]
发表于 2010-07-15 11:29 |只看该作者
回复  superhappy1


Linux内核代码并非只读的,参见10楼的代码,很多Rootkit的攻击目标就是内核代码
upczhsh 发表于 2010-07-15 10:43



    请问下,内核代码不只读的原因是什么呢?

论坛徽章:
0
32 [报告]
发表于 2010-07-15 12:06 |只看该作者
回复 31# new_learner


攻击者如果有办法修改内核(比如向内核中加载一个LKM),就已经有了ring 0的权限,
可以做任何事情,无法阻止

即使你在系统启动时将内核代码设置为只读的,攻击者仍然可以修改内核页表,把代码段的
保护属性设置为可读可写。。。

论坛徽章:
0
33 [报告]
发表于 2010-07-15 13:21 |只看该作者
回复  new_learner


攻击者如果有办法修改内核(比如向内核中加载一个LKM),就已经有了ring 0的权限,
可以做任何事情,无法阻止

即使你在系统启动时将内核代码设置为只读的,攻击者仍然可以修改内核页表,把代码段的
保护属性设置为可读可写。。。upczhsh 发表于 2010-07-15 12:06


是的,你说得没错。

但是,这不是内核代码的页被设置成可读可写的原因吧?

论坛徽章:
0
34 [报告]
发表于 2010-07-15 13:25 |只看该作者
回复 33# new_learner


    可能这也给随便挂钩子提供便利了吧。

论坛徽章:
0
35 [报告]
发表于 2010-07-15 13:38 |只看该作者
回复  new_learner


    可能这也给随便挂钩子提供便利了吧。
kgn28 发表于 2010-07-15 13:25



    我还是不太明白,为什么这会给“随便挂钩子”提供便利?

挂钩子又不会改变原来的代码内容。

论坛徽章:
0
36 [报告]
发表于 2010-07-15 13:47 |只看该作者
回复 35# new_learner


    不知道会不会有这么一种情况,就会譬如内核有一个静态变量p,加载某一模块,比如文件系统后,p = &q;,那么现在我要挂p的钩子,是不是就要修改p的内容呢?

论坛徽章:
0
37 [报告]
发表于 2010-07-15 13:59 |只看该作者
回复  new_learner


    不知道会不会有这么一种情况,就会譬如内核有一个静态变量p,加载某一模块,比 ...
kgn28 发表于 2010-07-15 13:47



    静态变量P不属于kernel code吧?

Figure 2-13 shows how the first 3 MB of RAM are filled by Linux. We have assumed that the kernel requires less than 3 MB of RAM.

The symbol _text, which corresponds to physical address 0x00100000, denotes the address of the first byte of kernel code. The end of the kernel code is similarly identified by the symbol _etext. Kernel data is divided into two groups: initialized and uninitialized. The initialized data starts right after _etext and ends at _edata. The uninitialized data follows and ends up at _end.

The symbols appearing in the figure are not defined in Linux source code; they are produced while compiling the kernel.

  • You can find the linear address of these symbols in the file System.map, which is created right after the kernel is compiled.






  • 在看一下is_kernel_text()的实现:

    1. static inline int is_kernel_text(unsigned long addr)
    2. {
    3.         if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext)
    4.                 return 1;
    5.         return in_gate_area_no_task(addr);
    6. }
    复制代码
    静态变量P应该在initialized区,也就是_etext到_edata这部分,不属于is_kernel_text的范围。

    论坛徽章:
    0
    38 [报告]
    发表于 2010-07-15 14:10 |只看该作者
    本帖最后由 kgn28 于 2010-07-15 14:12 编辑

    回复 37# new_learner


        恩,没错,我错了,我把代码和数据搞混了。{:3_191:}
    我写一个for循环,在_text开始的2M全部变成1,系统就卡住不动了。还真是想不出什么情况下需要修改内核代码的内容?这样就相当于修改内核代码了。而且是在运行时修改。难道和模块加载有关系???
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP