]> git.itanic.dy.fi Git - linux-stable/commitdiff
xfs: rename XFS_IGET_BULKSTAT to XFS_IGET_UNTRUSTED
authorDave Chinner <dchinner@redhat.com>
Mon, 10 Jan 2011 22:28:38 +0000 (15:28 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 2 Mar 2011 14:46:47 +0000 (09:46 -0500)
Upstream commit: 1920779e67cbf5ea8afef317777c5bf2b8096188

Inode numbers may come from somewhere external to the filesystem
(e.g. file handles, bulkstat information) and so are inherently
untrusted. Rename the flag we use for these lookups to make it
obvious we are doing a lookup of an untrusted inode number and need
to verify it completely before trying to read it from disk.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[dannf: backported to 2.6.32.y]
Cc: dann frazier <dannf@debian.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/xfs/linux-2.6/xfs_export.c
fs/xfs/xfs_ialloc.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h
fs/xfs/xfs_itable.c

index 87b8cbd23d4bc5a9e287dbfbea056d11994612cf..20b1c0dee440b045deb57308d340fe45806d3c32 100644 (file)
@@ -127,12 +127,11 @@ xfs_nfs_get_inode(
                return ERR_PTR(-ESTALE);
 
        /*
-        * The XFS_IGET_BULKSTAT means that an invalid inode number is just
-        * fine and not an indication of a corrupted filesystem.  Because
-        * clients can send any kind of invalid file handle, e.g. after
-        * a restore on the server we have to deal with this case gracefully.
+        * The XFS_IGET_UNTRUSTED means that an invalid inode number is just
+        * fine and not an indication of a corrupted filesystem as clients can
+        * send invalid file handles and we have to handle it gracefully..
         */
-       error = xfs_iget(mp, NULL, ino, XFS_IGET_BULKSTAT,
+       error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED,
                         XFS_ILOCK_SHARED, &ip, 0);
        if (error) {
                /*
index 1a1b7c924fe99c5f4fc0cb8b3b43a69ac68aa354..b15adc9be0398904f0ea79d1717014b49716e82e 100644 (file)
@@ -1256,7 +1256,7 @@ xfs_imap_lookup(
                return error;
 
        /* for untrusted inodes check it is allocated first */
-       if ((flags & XFS_IGET_BULKSTAT) &&
+       if ((flags & XFS_IGET_UNTRUSTED) &&
            (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino)))
                return EINVAL;
 
@@ -1297,8 +1297,11 @@ xfs_imap(
        if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks ||
            ino != XFS_AGINO_TO_INO(mp, agno, agino)) {
 #ifdef DEBUG
-               /* no diagnostics for bulkstat, ino comes from userspace */
-               if (flags & XFS_IGET_BULKSTAT)
+               /*
+                * Don't output diagnostic information for untrusted inodes
+                * as they can be invalid without implying corruption.
+                */
+               if (flags & XFS_IGET_UNTRUSTED)
                        return XFS_ERROR(EINVAL);
                if (agno >= mp->m_sb.sb_agcount) {
                        xfs_fs_cmn_err(CE_ALERT, mp,
@@ -1334,7 +1337,7 @@ xfs_imap(
         * inodes in stale state on disk. Hence we have to do a btree lookup
         * in all cases where an untrusted inode number is passed.
         */
-       if (flags & XFS_IGET_BULKSTAT) {
+       if (flags & XFS_IGET_UNTRUSTED) {
                error = xfs_imap_lookup(mp, tp, agno, agino, agbno,
                                        &chunk_agbno, &offset_agbno, flags);
                if (error)
index 523a1ae4964d6efef646469e1398c272cf1b0281..c2b85fd91eca22b29c7f58c54b2eb44bd587804d 100644 (file)
@@ -177,7 +177,7 @@ xfs_imap_to_bp(
                if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
                                                XFS_ERRTAG_ITOBP_INOTOBP,
                                                XFS_RANDOM_ITOBP_INOTOBP))) {
-                       if (iget_flags & XFS_IGET_BULKSTAT) {
+                       if (iget_flags & XFS_IGET_UNTRUSTED) {
                                xfs_trans_brelse(tp, bp);
                                return XFS_ERROR(EINVAL);
                        }
index 41555de1d1dbd4e6befcd64840712de5beff8235..e631e3f7012ed5371342106c00f47935dc682d23 100644 (file)
@@ -558,7 +558,7 @@ do { \
  * Flags for xfs_iget()
  */
 #define XFS_IGET_CREATE                0x1
-#define XFS_IGET_BULKSTAT      0x2
+#define XFS_IGET_UNTRUSTED     0x2
 
 int            xfs_inotobp(struct xfs_mount *, struct xfs_trans *,
                            xfs_ino_t, struct xfs_dinode **,
index 7006981598ab992f6b2b98e42573fdb5f7b454b9..4ffc7fd3d5d466f5fbcb3b81cc1ecc4387df77fc 100644 (file)
@@ -80,7 +80,7 @@ xfs_bulkstat_one_int(
                return XFS_ERROR(ENOMEM);
 
        error = xfs_iget(mp, NULL, ino,
-                        XFS_IGET_BULKSTAT, XFS_ILOCK_SHARED, &ip, bno);
+                        XFS_IGET_UNTRUSTED, XFS_ILOCK_SHARED, &ip, bno);
        if (error) {
                *stat = BULKSTAT_RV_NOTHING;
                goto out_free;