]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/xfs/linux-2.6/xfs_ioctl.c
xfs: prevent reading uninitialized stack memory
[net-next-2.6.git] / fs / xfs / linux-2.6 / xfs_ioctl.c
index e59a8106283069b24bb9fb4b5f0ea5bec92d8ede..3b9e626f7cd1562877cc340d0c43c5a776dd2e35 100644 (file)
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
-#include "xfs_dir2.h"
 #include "xfs_alloc.h"
-#include "xfs_dmapi.h"
 #include "xfs_mount.h"
 #include "xfs_bmap_btree.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir2_sf.h"
 #include "xfs_dinode.h"
 #include "xfs_inode.h"
 #include "xfs_ioctl.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
 #include "xfs_rtalloc.h"
 #include "xfs_itable.h"
 #include "xfs_error.h"
-#include "xfs_rw.h"
 #include "xfs_attr.h"
 #include "xfs_bmap.h"
 #include "xfs_buf_item.h"
@@ -794,6 +785,8 @@ xfs_ioc_fsgetxattr(
 {
        struct fsxattr          fa;
 
+       memset(&fa, 0, sizeof(struct fsxattr));
+
        xfs_ilock(ip, XFS_ILOCK_SHARED);
        fa.fsx_xflags = xfs_ip2xflags(ip);
        fa.fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog;
@@ -908,13 +901,20 @@ xfs_ioctl_setattr(
        struct xfs_dquot        *olddquot = NULL;
        int                     code;
 
-       xfs_itrace_entry(ip);
+       trace_xfs_ioctl_setattr(ip);
 
        if (mp->m_flags & XFS_MOUNT_RDONLY)
                return XFS_ERROR(EROFS);
        if (XFS_FORCED_SHUTDOWN(mp))
                return XFS_ERROR(EIO);
 
+       /*
+        * Disallow 32bit project ids because on-disk structure
+        * is 16bit only.
+        */
+       if ((mask & FSX_PROJID) && (fa->fsx_projid > (__uint16_t)-1))
+               return XFS_ERROR(EINVAL);
+
        /*
         * If disk quotas is on, we make sure that the dquots do exist on disk,
         * before we start any other transactions. Trying to do this later
@@ -1043,8 +1043,7 @@ xfs_ioctl_setattr(
                }
        }
 
-       xfs_trans_ijoin(tp, ip, lock_flags);
-       xfs_trans_ihold(tp, ip);
+       xfs_trans_ijoin(tp, ip);
 
        /*
         * Change file ownership.  Must be the owner or privileged.
@@ -1116,16 +1115,7 @@ xfs_ioctl_setattr(
        xfs_qm_dqrele(udqp);
        xfs_qm_dqrele(gdqp);
 
-       if (code)
-               return code;
-
-       if (DM_EVENT_ENABLED(ip, DM_EVENT_ATTRIBUTE)) {
-               XFS_SEND_NAMESP(mp, DM_EVENT_ATTRIBUTE, ip, DM_RIGHT_NULL,
-                               NULL, DM_RIGHT_NULL, NULL, NULL, 0, 0,
-                               (mask & FSX_NONBLOCK) ? DM_FLAGS_NDELAY : 0);
-       }
-
-       return 0;
+       return code;
 
  error_return:
        xfs_qm_dqrele(udqp);
@@ -1301,7 +1291,7 @@ xfs_file_ioctl(
        if (filp->f_mode & FMODE_NOCMTIME)
                ioflags |= IO_INVIS;
 
-       xfs_itrace_entry(ip);
+       trace_xfs_file_ioctl(ip);
 
        switch (cmd) {
        case XFS_IOC_ALLOCSP: