Skip to content

Commit

Permalink
xfs: don't leak EFSBADCRC to userspace
Browse files Browse the repository at this point in the history
While the verifier routines may return EFSBADCRC when a buffer has
a bad CRC, we need to translate that to EFSCORRUPTED so that the
higher layers treat the error appropriately and we return a
consistent error to userspace. This fixes a xfs/005 regression.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
  • Loading branch information
Dave Chinner authored and Dave Chinner committed Mar 7, 2014
1 parent 38dbfb5 commit ac75a1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/xfs/xfs_mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ xfs_readsb(
error = bp->b_error;
if (loud)
xfs_warn(mp, "SB validate failed with error %d.", error);
/* bad CRC means corrupted metadata */
if (error == EFSBADCRC)
error = EFSCORRUPTED;
goto release_buf;
}

Expand Down
4 changes: 4 additions & 0 deletions fs/xfs/xfs_symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ xfs_readlink_bmap(
if (error) {
xfs_buf_ioerror_alert(bp, __func__);
xfs_buf_relse(bp);

/* bad CRC means corrupted metadata */
if (error == EFSBADCRC)
error = EFSCORRUPTED;
goto out;
}
byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt);
Expand Down
11 changes: 11 additions & 0 deletions fs/xfs/xfs_trans_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ xfs_trans_read_buf_map(
XFS_BUF_UNDONE(bp);
xfs_buf_stale(bp);
xfs_buf_relse(bp);

/* bad CRC means corrupted metadata */
if (error == EFSBADCRC)
error = EFSCORRUPTED;
return error;
}
#ifdef DEBUG
Expand Down Expand Up @@ -338,6 +342,9 @@ xfs_trans_read_buf_map(
if (tp->t_flags & XFS_TRANS_DIRTY)
xfs_force_shutdown(tp->t_mountp,
SHUTDOWN_META_IO_ERROR);
/* bad CRC means corrupted metadata */
if (error == EFSBADCRC)
error = EFSCORRUPTED;
return error;
}
}
Expand Down Expand Up @@ -375,6 +382,10 @@ xfs_trans_read_buf_map(
if (tp->t_flags & XFS_TRANS_DIRTY)
xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR);
xfs_buf_relse(bp);

/* bad CRC means corrupted metadata */
if (error == EFSBADCRC)
error = EFSCORRUPTED;
return error;
}
#ifdef DEBUG
Expand Down

0 comments on commit ac75a1f

Please sign in to comment.