Skip to content

Commit 11d9104

Browse files
djwongBrian Maly
authored andcommitted
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]> (cherry picked from commit 9c92ee2) Orabug: 31034071 Signed-off-by: Junxiao Bi <[email protected]> Reviewed-by: Wengang Wang <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent 1c656ff commit 11d9104

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
@@ -613,6 +613,7 @@ xfs_log_mount(
613613
xfs_daddr_t blk_offset,
614614
int num_bblks)
615615
{
616+
bool fatal = xfs_sb_version_hascrc(&mp->m_sb);
616617
int error = 0;
617618
int min_logfsbs;
618619

@@ -664,9 +665,20 @@ xfs_log_mount(
664665
XFS_FSB_TO_B(mp, mp->m_sb.sb_logblocks),
665666
XFS_MAX_LOG_BYTES);
666667
error = -EINVAL;
668+
} else if (mp->m_sb.sb_logsunit > 1 &&
669+
mp->m_sb.sb_logsunit % mp->m_sb.sb_blocksize) {
670+
xfs_warn(mp,
671+
"log stripe unit %u bytes must be a multiple of block size",
672+
mp->m_sb.sb_logsunit);
673+
error = -EINVAL;
674+
fatal = true;
667675
}
668676
if (error) {
669-
if (xfs_sb_version_hascrc(&mp->m_sb)) {
677+
/*
678+
* Log check errors are always fatal on v5; or whenever bad
679+
* metadata leads to a crash.
680+
*/
681+
if (fatal) {
670682
xfs_crit(mp, "AAIEEE! Log failed size checks. Abort!");
671683
ASSERT(0);
672684
goto out_free_log;

0 commit comments

Comments
 (0)