]> 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 181dd90b29ceed17af01a73909195912719edbaa..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"
@@ -129,7 +127,7 @@ xfs_qm_parseargs(
                return XFS_ERROR(EINVAL);
        }
 
-       PVFS_PARSEARGS(BHV_NEXT(bhv), options, args, update, error);
+       error = bhv_next_vfs_parseargs(BHV_NEXT(bhv), options, args, update);
        if (!error && !referenced)
                bhv_remove_vfsops(bhvtovfs(bhv), VFS_POSITION_QM);
        return error;
@@ -140,9 +138,8 @@ xfs_qm_showargs(
        struct bhv_desc         *bhv,
        struct seq_file         *m)
 {
-       struct vfs              *vfsp = bhvtovfs(bhv);
+       struct bhv_vfs          *vfsp = bhvtovfs(bhv);
        struct xfs_mount        *mp = XFS_VFSTOM(vfsp);
-       int                     error;
 
        if (mp->m_qflags & XFS_UQUOTA_ACCT) {
                (mp->m_qflags & XFS_UQUOTA_ENFD) ?
@@ -165,8 +162,7 @@ xfs_qm_showargs(
        if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
                seq_puts(m, "," MNTOPT_NOQUOTA);
 
-       PVFS_SHOWARGS(BHV_NEXT(bhv), m, error);
-       return error;
+       return bhv_next_vfs_showargs(BHV_NEXT(bhv), m);
 }
 
 STATIC int
@@ -175,14 +171,12 @@ xfs_qm_mount(
        struct xfs_mount_args   *args,
        struct cred             *cr)
 {
-       struct vfs              *vfsp = bhvtovfs(bhv);
+       struct bhv_vfs          *vfsp = bhvtovfs(bhv);
        struct xfs_mount        *mp = XFS_VFSTOM(vfsp);
-       int                     error;
 
        if (args->flags & (XFSMNT_UQUOTA | XFSMNT_GQUOTA | XFSMNT_PQUOTA))
                xfs_qm_mount_quotainit(mp, args->flags);
-       PVFS_MOUNT(BHV_NEXT(bhv), args, cr, error);
-       return error;
+       return bhv_next_vfs_mount(BHV_NEXT(bhv), args, cr);
 }
 
 /*
@@ -195,8 +189,8 @@ xfs_qm_mount(
 STATIC int
 xfs_qm_statvfs(
        struct bhv_desc         *bhv,
-       xfs_statfs_t            *statp,
-       struct vnode            *vnode)
+       bhv_statvfs_t           *statp,
+       struct bhv_vnode        *vnode)
 {
        xfs_mount_t             *mp;
        xfs_inode_t             *ip;
@@ -205,11 +199,11 @@ xfs_qm_statvfs(
        __uint64_t              limit;
        int                     error;
 
-       error = PVFS_STATVFS(BHV_NEXT(bhv), statp, vnode);
+       error = bhv_next_vfs_statvfs(BHV_NEXT(bhv), statp, vnode);
        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))
@@ -223,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);
@@ -246,7 +247,7 @@ xfs_qm_syncall(
        int                     flags,
        cred_t                  *credp)
 {
-       struct vfs              *vfsp = bhvtovfs(bhv);
+       struct bhv_vfs          *vfsp = bhvtovfs(bhv);
        struct xfs_mount        *mp = XFS_VFSTOM(vfsp);
        int                     error;
 
@@ -265,8 +266,7 @@ xfs_qm_syncall(
                        }
                }
        }
-       PVFS_SYNC(BHV_NEXT(bhv), flags, credp, error);
-       return error;
+       return bhv_next_vfs_sync(BHV_NEXT(bhv), flags, credp);
 }
 
 STATIC int
@@ -401,7 +401,7 @@ STATIC struct xfs_qmops xfs_qmcore_xfs = {
        .xfs_dqtrxops           = &xfs_trans_dquot_ops,
 };
 
-struct bhv_vfsops xfs_qmops = { {
+struct bhv_module_vfsops xfs_qmops = { {
        BHV_IDENTITY_INIT(VFS_BHV_QM, VFS_POSITION_QM),
        .vfs_parseargs          = xfs_qm_parseargs,
        .vfs_showargs           = xfs_qm_showargs,