diff mbox

[03/55] xfs: complain if we don't get nextents bmap records

Message ID 148072893359.12995.10240545634733611493.stgit@birch.djwong.org (mailing list archive)
State Accepted
Headers show

Commit Message

Darrick J. Wong Dec. 3, 2016, 1:35 a.m. UTC
When reading into memory all extents of a btree-format inode fork,
complain if the number of extents we find is not the same as the number
of extents reported in the inode core.  This is needed to stop an IO
action from accessing the garbage areas of the in-core fork.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_bmap.c |    2 ++
 1 file changed, 2 insertions(+)



--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Dave Chinner Dec. 5, 2016, 1:35 a.m. UTC | #1
On Fri, Dec 02, 2016 at 05:35:33PM -0800, Darrick J. Wong wrote:
> When reading into memory all extents of a btree-format inode fork,
> complain if the number of extents we find is not the same as the number
> of extents reported in the inode core.  This is needed to stop an IO
> action from accessing the garbage areas of the in-core fork.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/libxfs/xfs_bmap.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 6f28814..9821161 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -1375,6 +1375,8 @@ xfs_bmap_read_extents(
>  			return error;
>  		block = XFS_BUF_TO_BLOCK(bp);
>  	}
> +	if (i != XFS_IFORK_NEXTENTS(ip, whichfork))
> +		return -EFSCORRUPTED;
>  	ASSERT(i == xfs_iext_count(ifp));
>  	ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork));

This assert is now redundant and can be removed (which I've done).

Cheers,

Dave.
diff mbox

Patch

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 6f28814..9821161 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1375,6 +1375,8 @@  xfs_bmap_read_extents(
 			return error;
 		block = XFS_BUF_TO_BLOCK(bp);
 	}
+	if (i != XFS_IFORK_NEXTENTS(ip, whichfork))
+		return -EFSCORRUPTED;
 	ASSERT(i == xfs_iext_count(ifp));
 	ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork));
 	XFS_BMAP_TRACE_EXLIST(ip, i, whichfork);