[Top] [All Lists]

[PATCH 03/13] libxfs: xfs_sb_read_verify() doesn't flag bad crcs on prim

To: xfs@xxxxxxxxxxx
Subject: [PATCH 03/13] libxfs: xfs_sb_read_verify() doesn't flag bad crcs on primary sb
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Tue, 4 Mar 2014 19:51:47 +1100
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1393923117-9559-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1393923117-9559-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

[userspace port]

My earlier commit 10e6e65 deserves a layer or two of brown paper
bags.  The logic in that commit means that a CRC failure on the
primary superblock will *never* result in an error return.

Hopefully this fixes it, so that we always return the error
if it's a primary superblock, otherwise only if the filesystem
has CRCs enabled.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
 libxfs/xfs_sb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c
index 4be7366..5c10c97 100644
--- a/libxfs/xfs_sb.c
+++ b/libxfs/xfs_sb.c
@@ -569,7 +569,7 @@ xfs_sb_read_verify(
                if (!xfs_verify_cksum(bp->b_addr, be16_to_cpu(dsb->sb_sectsize),
                                      offsetof(struct xfs_sb, sb_crc))) {
                        /* Only fail bad secondaries on a known V5 filesystem */
-                       if (bp->b_bn != XFS_SB_DADDR &&
+                       if (bp->b_bn == XFS_SB_DADDR ||
                            xfs_sb_version_hascrc(&mp->m_sb)) {
                                error = EFSCORRUPTED;
                                goto out_error;

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