]> err.no Git - linux-2.6/blobdiff - fs/xfs/quota/xfs_qm_bhv.c
[XFS] Fix a bad pointer dereference in the quota statvfs handling.
[linux-2.6] / fs / xfs / quota / xfs_qm_bhv.c
index ad9ab104946ae41e7861aa334b562fcd2c5f7d63..db8872be8c87cfa5b8cef85569511db2c225f58b 100644 (file)
@@ -24,7 +24,6 @@
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
-#include "xfs_dir.h"
 #include "xfs_dir2.h"
 #include "xfs_alloc.h"
 #include "xfs_dmapi.h"
@@ -33,7 +32,6 @@
 #include "xfs_bmap_btree.h"
 #include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
-#include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
 #include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
@@ -191,7 +189,7 @@ xfs_qm_mount(
 STATIC int
 xfs_qm_statvfs(
        struct bhv_desc         *bhv,
-       xfs_statfs_t            *statp,
+       bhv_statvfs_t           *statp,
        struct bhv_vnode        *vnode)
 {
        xfs_mount_t             *mp;
@@ -205,7 +203,7 @@ xfs_qm_statvfs(
        if (error || !vnode)
                return error;
 
-       mp = XFS_BHVTOM(bhv);
+       mp = xfs_vfstom(bhvtovfs(bhv));
        ip = xfs_vtoi(vnode);
 
        if (!(ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT))
@@ -219,17 +217,24 @@ xfs_qm_statvfs(
                return 0;
        dp = &dqp->q_core;
 
-       limit = dp->d_blk_softlimit ? dp->d_blk_softlimit : dp->d_blk_hardlimit;
+       limit = dp->d_blk_softlimit ?
+               be64_to_cpu(dp->d_blk_softlimit) :
+               be64_to_cpu(dp->d_blk_hardlimit);
        if (limit && statp->f_blocks > limit) {
                statp->f_blocks = limit;
-               statp->f_bfree = (statp->f_blocks > dp->d_bcount) ?
-                                       (statp->f_blocks - dp->d_bcount) : 0;
+               statp->f_bfree =
+                       (statp->f_blocks > be64_to_cpu(dp->d_bcount)) ?
+                        (statp->f_blocks - be64_to_cpu(dp->d_bcount)) : 0;
        }
-       limit = dp->d_ino_softlimit ? dp->d_ino_softlimit : dp->d_ino_hardlimit;
+
+       limit = dp->d_ino_softlimit ?
+               be64_to_cpu(dp->d_ino_softlimit) :
+               be64_to_cpu(dp->d_ino_hardlimit);
        if (limit && statp->f_files > limit) {
                statp->f_files = limit;
-               statp->f_ffree = (statp->f_files > dp->d_icount) ?
-                                       (statp->f_ffree - dp->d_icount) : 0;
+               statp->f_ffree =
+                       (statp->f_files > be64_to_cpu(dp->d_icount)) ?
+                        (statp->f_ffree - be64_to_cpu(dp->d_icount)) : 0;
        }
 
        xfs_qm_dqput(dqp);