提交 556b8883 编写于 作者: D Dave Chinner 提交者: Dave Chinner

xfs: xfs_readsb needs to check for magic numbers

Commit daba5427 ("xfs: skip verification on initial "guess"
superblock read") dropped the use of a verifier for the initial
superblock read so we can probe the sector size of the filesystem
stored in the superblock. It, however, now fails to validate that
what was read initially is actually an XFS superblock and hence will
fail the sector size check and return ENOSYS.

This causes probe-based mounts to fail because it expects XFS to
return EINVAL when it doesn't recognise the superblock format.

cc: <stable@vger.kernel.org>
Reported-by: NPlamen Petrov <plamen.sisi@gmail.com>
Tested-by: NPlamen Petrov <plamen.sisi@gmail.com>
Signed-off-by: NDave Chinner <dchinner@redhat.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NDave Chinner <david@fromorbit.com>
上级 1f6d6482
......@@ -323,8 +323,19 @@ xfs_readsb(
/*
* Initialize the mount structure from the superblock.
*/
xfs_sb_from_disk(&mp->m_sb, XFS_BUF_TO_SBP(bp));
xfs_sb_quota_from_disk(&mp->m_sb);
xfs_sb_from_disk(sbp, XFS_BUF_TO_SBP(bp));
xfs_sb_quota_from_disk(sbp);
/*
* If we haven't validated the superblock, do so now before we try
* to check the sector size and reread the superblock appropriately.
*/
if (sbp->sb_magicnum != XFS_SB_MAGIC) {
if (loud)
xfs_warn(mp, "Invalid superblock magic number");
error = EINVAL;
goto release_buf;
}
/*
* We must be able to do sector-sized and sector-aligned IO.
......@@ -337,11 +348,11 @@ xfs_readsb(
goto release_buf;
}
/*
* Re-read the superblock so the buffer is correctly sized,
* and properly verified.
*/
if (buf_ops == NULL) {
/*
* Re-read the superblock so the buffer is correctly sized,
* and properly verified.
*/
xfs_buf_relse(bp);
sector_size = sbp->sb_sectsize;
buf_ops = loud ? &xfs_sb_buf_ops : &xfs_sb_quiet_buf_ops;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册