Skip to content

Commit fcfbe2c

Browse files
Dave Chinnerdchinner
authored andcommitted
xfs: log recovery needs to validate against sb_meta_uuid
Now that sb_uuid can be changed by the user, we cannot use this to validate the metadata blocks being recovered belong to this filesystem. We must check against the sb_meta_uuid as that will remain unchanged. There is a complication in this code - the superblock itself. We can not check the sb_meta_uuid unconditionally, as that may not be set on disk. Hence we must verify the superblock sb_uuid matches between the log record and the in-core superblock. Found by inspection after the previous two problems were found. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
1 parent ac383de commit fcfbe2c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

fs/xfs/xfs_log_recover.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,15 +1890,25 @@ xlog_recover_get_buf_lsn(
18901890
uuid = &((struct xfs_attr3_rmt_hdr *)blk)->rm_uuid;
18911891
break;
18921892
case XFS_SB_MAGIC:
1893+
/*
1894+
* superblock uuids are magic. We may or may not have a
1895+
* sb_meta_uuid on disk, but it will be set in the in-core
1896+
* superblock. We set the uuid pointer for verification
1897+
* according to the superblock feature mask to ensure we check
1898+
* the relevant UUID in the superblock.
1899+
*/
18931900
lsn = be64_to_cpu(((struct xfs_dsb *)blk)->sb_lsn);
1894-
uuid = &((struct xfs_dsb *)blk)->sb_uuid;
1901+
if (xfs_sb_version_hasmetauuid(&mp->m_sb))
1902+
uuid = &((struct xfs_dsb *)blk)->sb_meta_uuid;
1903+
else
1904+
uuid = &((struct xfs_dsb *)blk)->sb_uuid;
18951905
break;
18961906
default:
18971907
break;
18981908
}
18991909

19001910
if (lsn != (xfs_lsn_t)-1) {
1901-
if (!uuid_equal(&mp->m_sb.sb_uuid, uuid))
1911+
if (!uuid_equal(&mp->m_sb.sb_meta_uuid, uuid))
19021912
goto recover_immediately;
19031913
return lsn;
19041914
}

0 commit comments

Comments
 (0)