Chinaunix首页 | 论坛 | 博客
  • 博客访问: 590498
  • 博文数量: 197
  • 博客积分: 7001
  • 博客等级: 大校
  • 技术积分: 2155
  • 用 户 组: 普通用户
  • 注册时间: 2005-02-24 00:29
文章分类

全部博文(197)

文章存档

2022年(1)

2019年(2)

2015年(1)

2012年(100)

2011年(69)

2010年(14)

2007年(3)

2005年(7)

分类: LINUX

2011-03-21 17:34:26

     对Linux Kernel Exploit没有了解,但从近几年Lwn.net的文章看来,Linux内核的安全性还有很大的改进空间,Linus负有一定责任。下面是读了

有总结性文字:
The most general exploitation techniques involving kernel SLUB/SLAB corruption involve manipulating heap state such that an object that can be overflowed by the attacker resides
immediately before another object whose contents are worth overwriting, or overflowing into the page following the slab.  The most common known techniques involve overflowing into an allocated object with useful contents such as a function pointer and then triggering these (various IPC-related structs are often used for this).  It's also possible to overflow into a free object and overwrite its free pointer, causing subsequent allocations to result in a fake heap object residing in userland being under an attacker's control.

下面是个人小结:
1 copy_from_user 是源头,如果不检查size大小,来自用户态的数据就可能overflow 为之准备的缓冲区(往往是slab或slub对象)
2 任何用户可读 /proc/slabinfo,容易得到对象的layout信息,这就是lwn.net讨论的。
3 SLUB 把不同类型 但是相同大小的对象归一处理,用同一个缓冲池维护。而且空闲对象是连续分配(而不是random布局)
4 Slub 把刚释放的对象先分配出去
5 有些slub对象含有函数指针,如果能替换成攻击者的函数,则取得了root权限

如何攻击:
(1)找到一个误用copy_from_user 的地方,没有检查size。
(2)寻找copy_from_user 所使用的slub对象大小,找到可以利用的slub对象类型,例如IPC对象含有对象指针
(3)利用 /proc/slabinfo信息耗光缓冲池中已有的对象,这样将refill,然后再连续申请,这样的slub对象位于同一个页面,肯定是物理连续的,而后释放中间的一个
(4)调用copy_from_user ,写更多的数据(包括准备好的用户态函数指针),这样的话将overflow到随后的那个对象,原有的指针被覆盖,触发执行即可。

阅读(1786) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~