Skip to content

Commit 9c92ee2

Browse files
committed
xfs: validate sb_logsunit is a multiple of the fs blocksize
Make sure the log stripe unit is sane before proceeding with mounting. AFAICT this means that logsunit has to be 0, 1, or a multiple of the fs block size. Found this by setting the LSB of logsunit in xfs/350 and watching the system crash as soon as we try to write to the log. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Brian Foster <[email protected]>
1 parent f1b92bb commit 9c92ee2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

fs/xfs/xfs_log.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ xfs_log_mount(
608608
xfs_daddr_t blk_offset,
609609
int num_bblks)
610610
{
611+
bool fatal = xfs_sb_version_hascrc(&mp->m_sb);
611612
int error = 0;
612613
int min_logfsbs;
613614

@@ -659,9 +660,20 @@ xfs_log_mount(
659660
XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks),
660661
XFS_MAX_LOG_BYTES);
661662
error = -EINVAL;
663+
} else if (mp->m_sb.sb_logsunit > 1 &&
664+
mp->m_sb.sb_logsunit % mp->m_sb.sb_blocksize) {
665+
xfs_warn(mp,
666+
"log stripe unit %u bytes must be a multiple of block size",
667+
mp->m_sb.sb_logsunit);
668+
error = -EINVAL;
669+
fatal = true;
662670
}
663671
if (error) {
664-
if (xfs_sb_version_hascrc(&mp->m_sb)) {
672+
/*
673+
* Log check errors are always fatal on v5; or whenever bad
674+
* metadata leads to a crash.
675+
*/
676+
if (fatal) {
665677
xfs_crit(mp, "AAIEEE! Log failed size checks. Abort!");
666678
ASSERT(0);
667679
goto out_free_log;

0 commit comments

Comments
 (0)