[Top] [All Lists]

[PATCH 5/5] xfs: use xfs_ialloc_blks_per_cluster in xfs_imap

To: "xfs@xxxxxxxxxxx" <xfs@xxxxxxxxxxx>
Subject: [PATCH 5/5] xfs: use xfs_ialloc_blks_per_cluster in xfs_imap
From: Jeff Liu <jeff.liu@xxxxxxxxxx>
Date: Wed, 11 Dec 2013 21:48:35 +0800
Delivered-to: xfs@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0
From: Jie Liu <jeff.liu@xxxxxxxxxx>

Use xfs_ialloc_blks_per_cluster() in xfs_imap().  Please note that we
previously calculate the number of blocks per cluster without taking
the situation of that the inode cluster size might be equal to or less
than the SB blocksize into account.  Maybe there is a chance to cause
potential issues after handling an untrusted inode number lookup and
proceed to check if the inode number maps to a block is outsides the
file system bounds or not.

Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
 fs/xfs/xfs_ialloc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 30018f6..6c28820 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -1377,8 +1377,7 @@ xfs_imap(
                return XFS_ERROR(EINVAL);
-       blks_per_cluster = XFS_INODE_CLUSTER_SIZE(mp) >> mp->m_sb.sb_blocklog;
+       blks_per_cluster = xfs_ialloc_blks_per_cluster(mp);
         * For bulkstat and handle lookups, we have an untrusted inode number
         * that we have to verify is valid. We cannot do this just by reading
@@ -1398,7 +1397,7 @@ xfs_imap(
         * If the inode cluster size is the same as the blocksize or
         * smaller we get to the buffer by simple arithmetics.
-       if (XFS_INODE_CLUSTER_SIZE(mp) <= mp->m_sb.sb_blocksize) {
+       if (blks_per_cluster == 1) {
                offset = XFS_INO_TO_OFFSET(mp, ino);
                ASSERT(offset < mp->m_sb.sb_inopblock);

<Prev in Thread] Current Thread [Next in Thread>