Linux内核高危漏洞:一命令可攻擊所有Li … - Linux

By Quintina
at 2009-08-18T09:18
at 2009-08-18T09:18
Table of Contents
※ 引述《coldnew (夜影)》之銘言:
: 怎都沒人再講這消息呢......?
: 這是國外hacker 於 8/11 發布的bug
: http://baoz.net/linux-sockops-wrap-proto-ops-local-root-exploit/
: 經過測試,我負責的 bbs server(Debian Linux) 淪陷
: 自己的linux(Gentoo Linux) 也中招
: 所以請各位朋友注意一下囉
這個漏洞可以分成兩個部份
1. NULL pointer dereference in Kernel
2. mmap to 0
這個漏洞是另用 sock_sendfile() 導致 NULL pointer dereference。
通常 NULL pointer dereference 會產生 kernel crash or oops ,
因為 NULL 通常不是合法的位址。但是在 VM 裡,它就是 first page。如果
user application 可以 mmap first page (mmap to 0),那麼這個
NULL 就是合法的。
在這種情況下 kernel 去執行 NULL ( function pointer ),就等於執行
user application。
就以 sock_sendfile() 來看好了:
727static ssize_t sock_sendpage(struct file *file, struct page *page,
728 int offset, size_t size, loff_t *ppos, int more)
729{
730 struct socket *sock;
731 int flags;
732
733 sock = file->private_data;
734
735 flags = !(file->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT;
736 if (more)
737 flags |= MSG_MORE;
738
739 return sock->ops->sendpage(sock, page, offset, size, flags);
740}
注意 739 行,如果 sendpage 沒有初始,那 sock->ops->sendpage 就會是 NULL。
NULL pointer dereference 是一個相當嚴重的問題,所以在 2.6.23 之後,
有一個 kernel 變數 "mmap_min_addr" 來限制 user 可以 mmap 的最低位址,
來避免類似的事件發生。
mmap_min_addr 也造成了一些問題,某些 legacy code 需要 mmap to 0 。
因此 SELinux 的 policy 裡面有一個 mmap_zero,Redhat的預設是允許 mmap to 0。
這就是為什麼有些人有 SELinux 反而還比較不安全。
利用 Brad Spengler 的程式在自己的機器上沒有執行出來不代表機器沒有風險。
也許 SELinux 在 disabled 的狀態加上 mmap_min_addr 不是零的情況之下使得
這個 exploit 沒有成功。不知情的人認為他的機器是安全的,之後如果因為某些需求
安裝了 Wine,這個特別的程式需要 mmap to 0。在官方網站的指引之下,就把
mmap_min_addr 設成 0 了。
(http://wiki.winehq.org/PreloaderPageZeroProblem) 。
所以 Securityfocus 幾乎把所有 2.6.x 跟 2.4.x 都列為 "Vulnerable"
不是沒有道理的。(http://www.securityfocus.com/bid/36038)
Pulseaudio 則是另外一個利用 NULL pointer 的 exploit,有興趣的人可以
去看看 LWN 的文章(http://lwn.net/Articles/342330/)。
事實上也未必要 mmap to 0,只是這個是「比較可能」發生的 kernel bug。
--
: 怎都沒人再講這消息呢......?
: 這是國外hacker 於 8/11 發布的bug
: http://baoz.net/linux-sockops-wrap-proto-ops-local-root-exploit/
: 經過測試,我負責的 bbs server(Debian Linux) 淪陷
: 自己的linux(Gentoo Linux) 也中招
: 所以請各位朋友注意一下囉
這個漏洞可以分成兩個部份
1. NULL pointer dereference in Kernel
2. mmap to 0
這個漏洞是另用 sock_sendfile() 導致 NULL pointer dereference。
通常 NULL pointer dereference 會產生 kernel crash or oops ,
因為 NULL 通常不是合法的位址。但是在 VM 裡,它就是 first page。如果
user application 可以 mmap first page (mmap to 0),那麼這個
NULL 就是合法的。
在這種情況下 kernel 去執行 NULL ( function pointer ),就等於執行
user application。
就以 sock_sendfile() 來看好了:
727static ssize_t sock_sendpage(struct file *file, struct page *page,
728 int offset, size_t size, loff_t *ppos, int more)
729{
730 struct socket *sock;
731 int flags;
732
733 sock = file->private_data;
734
735 flags = !(file->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT;
736 if (more)
737 flags |= MSG_MORE;
738
739 return sock->ops->sendpage(sock, page, offset, size, flags);
740}
注意 739 行,如果 sendpage 沒有初始,那 sock->ops->sendpage 就會是 NULL。
NULL pointer dereference 是一個相當嚴重的問題,所以在 2.6.23 之後,
有一個 kernel 變數 "mmap_min_addr" 來限制 user 可以 mmap 的最低位址,
來避免類似的事件發生。
mmap_min_addr 也造成了一些問題,某些 legacy code 需要 mmap to 0 。
因此 SELinux 的 policy 裡面有一個 mmap_zero,Redhat的預設是允許 mmap to 0。
這就是為什麼有些人有 SELinux 反而還比較不安全。
利用 Brad Spengler 的程式在自己的機器上沒有執行出來不代表機器沒有風險。
也許 SELinux 在 disabled 的狀態加上 mmap_min_addr 不是零的情況之下使得
這個 exploit 沒有成功。不知情的人認為他的機器是安全的,之後如果因為某些需求
安裝了 Wine,這個特別的程式需要 mmap to 0。在官方網站的指引之下,就把
mmap_min_addr 設成 0 了。
(http://wiki.winehq.org/PreloaderPageZeroProblem) 。
所以 Securityfocus 幾乎把所有 2.6.x 跟 2.4.x 都列為 "Vulnerable"
不是沒有道理的。(http://www.securityfocus.com/bid/36038)
Pulseaudio 則是另外一個利用 NULL pointer 的 exploit,有興趣的人可以
去看看 LWN 的文章(http://lwn.net/Articles/342330/)。
事實上也未必要 mmap to 0,只是這個是「比較可能」發生的 kernel bug。
--
Tags:
Linux
All Comments

By Isla
at 2009-08-21T05:47
at 2009-08-21T05:47

By Emma
at 2009-08-23T19:25
at 2009-08-23T19:25

By Regina
at 2009-08-27T19:13
at 2009-08-27T19:13

By Anonymous
at 2009-08-28T05:13
at 2009-08-28T05:13

By Yuri
at 2009-08-30T10:25
at 2009-08-30T10:25
Related Posts
升級kernel 到 2.6.30後 無線網路掛點...(ubuntu9.04)

By Madame
at 2009-08-18T01:48
at 2009-08-18T01:48
Linux内核高危漏洞:一命令可攻擊所有Li …

By Rebecca
at 2009-08-18T01:24
at 2009-08-18T01:24
linux下是否有好用的mms server ?

By Connor
at 2009-08-18T01:16
at 2009-08-18T01:16
iptables 中的 nat

By Connor
at 2009-08-17T23:53
at 2009-08-17T23:53
關於root的問題

By Adele
at 2009-08-17T23:51
at 2009-08-17T23:51