aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-06-06 02:00:43 -0400
committerDave Chinner <david@fromorbit.com>2014-06-06 02:00:43 -0400
commit556b8883cfac3d3203557e161ea8005f8b5479b2 (patch)
treed928587238b976cd90ef90494769eab3af6f95c4
parent1f6d64829db78a7e1d63e15c9f48f0a5d2b5a679 (diff)
xfs: xfs_readsb needs to check for magic numbers
Commit daba542 ("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: Plamen Petrov <plamen.sisi@gmail.com> Tested-by: Plamen Petrov <plamen.sisi@gmail.com> Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_mount.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 944f3d9456a8..a9e29ea37620 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -323,8 +323,19 @@ reread:
323 /* 323 /*
324 * Initialize the mount structure from the superblock. 324 * Initialize the mount structure from the superblock.
325 */ 325 */
326 xfs_sb_from_disk(&mp->m_sb, XFS_BUF_TO_SBP(bp)); 326 xfs_sb_from_disk(sbp, XFS_BUF_TO_SBP(bp));
327 xfs_sb_quota_from_disk(&mp->m_sb); 327 xfs_sb_quota_from_disk(sbp);
328
329 /*
330 * If we haven't validated the superblock, do so now before we try
331 * to check the sector size and reread the superblock appropriately.
332 */
333 if (sbp->sb_magicnum != XFS_SB_MAGIC) {
334 if (loud)
335 xfs_warn(mp, "Invalid superblock magic number");
336 error = EINVAL;
337 goto release_buf;
338 }
328 339
329 /* 340 /*
330 * We must be able to do sector-sized and sector-aligned IO. 341 * We must be able to do sector-sized and sector-aligned IO.
@@ -337,11 +348,11 @@ reread:
337 goto release_buf; 348 goto release_buf;
338 } 349 }
339 350
340 /*
341 * Re-read the superblock so the buffer is correctly sized,
342 * and properly verified.
343 */
344 if (buf_ops == NULL) { 351 if (buf_ops == NULL) {
352 /*
353 * Re-read the superblock so the buffer is correctly sized,
354 * and properly verified.
355 */
345 xfs_buf_relse(bp); 356 xfs_buf_relse(bp);
346 sector_size = sbp->sb_sectsize; 357 sector_size = sbp->sb_sectsize;
347 buf_ops = loud ? &xfs_sb_buf_ops : &xfs_sb_quiet_buf_ops; 358 buf_ops = loud ? &xfs_sb_buf_ops : &xfs_sb_quiet_buf_ops;