CVE-2015-8660 OverlayFS文件系统权限检查缺陷漏洞

  overlayfs是目前使用比较广泛的层次文件系统,实现简单,性能较好. 可以充分利用不同或则相同overlay文件系统的page cache,具有
  1.上下合并
  2.同名遮盖
  3.写时拷贝
等特点。

  在FS/overlayfs/inode.c中的ovl_setattr()函数里,当用户对底层目录的文件进行修改时,会将原文件复制一份到上层目录,在这个过程中没有对文件的权限进行检查,导致用户可以利用overlayfs绕过文件系统权限检查。
  附一段更详细的解释:  
  The bug is in being too enthusiastic about optimizing ->setattr() away - instead of “copy verbatim with metadata” + “chmod/chown/utimes” (with the former being always safe and the latter failing in case of insufficient permissions) it tries to combine these two. Note that copyup itself will have to do ->setattr() anyway; that is where the elevated capabilities are right. Having these two ->setattr() (one to set verbatim copy of metadata, another to do what overlayfs ->setattr() had been asked to do in the first place) combined is where it breaks.

这个漏洞影响的系统内核版本:

LinuxKernel 3.18.x
LinuxKernel 4.1.x
LinuxKernel 4.2.x
LinuxKernel 4.3.x 

先附上一段可以正常执行提权的代码,里面还保留着我的调试信息,因为生成了好几个子程序,不会用GDB跟踪调试。这段代码改编自exploit-db上给出的poc,删除了部分代码后发现还是能运行,所以就用这个代码了

/*************************************************************************
    > File Name       : overlayfs.c
    > Author          : 何能斌
    > Mail            : enjoy5512@163.com 
    > Created Time    : Tue 15 Mar 2016 01:01:22 AM PDT
    > Remake          :
        这个程序是我根据exploit-db.com上给出的POC文档改编而来,因为多进程
        我不会调试,所以只能加入很多输出来查看程序运行的流程,在程序能正常
        运行的基础上删除了很多头文件,少用了一次fork()
 ************************************************************************/

#include
#include
#include
#include
#include
#include
#include

你可能感兴趣的:(Linux本地提权漏洞,漏洞)