Skip to content

Commit ac75a1f

Browse files
dgchinnerdchinner
authored andcommitted
xfs: don't leak EFSBADCRC to userspace
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>
1 parent 38dbfb5 commit ac75a1f

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

fs/xfs/xfs_mount.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ xfs_readsb(
307307
error = bp->b_error;
308308
if (loud)
309309
xfs_warn(mp, "SB validate failed with error %d.", error);
310+
/* bad CRC means corrupted metadata */
311+
if (error == EFSBADCRC)
312+
error = EFSCORRUPTED;
310313
goto release_buf;
311314
}
312315

fs/xfs/xfs_symlink.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ xfs_readlink_bmap(
8080
if (error) {
8181
xfs_buf_ioerror_alert(bp, __func__);
8282
xfs_buf_relse(bp);
83+
84+
/* bad CRC means corrupted metadata */
85+
if (error == EFSBADCRC)
86+
error = EFSCORRUPTED;
8387
goto out;
8488
}
8589
byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt);

fs/xfs/xfs_trans_buf.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ xfs_trans_read_buf_map(
275275
XFS_BUF_UNDONE(bp);
276276
xfs_buf_stale(bp);
277277
xfs_buf_relse(bp);
278+
279+
/* bad CRC means corrupted metadata */
280+
if (error == EFSBADCRC)
281+
error = EFSCORRUPTED;
278282
return error;
279283
}
280284
#ifdef DEBUG
@@ -338,6 +342,9 @@ xfs_trans_read_buf_map(
338342
if (tp->t_flags & XFS_TRANS_DIRTY)
339343
xfs_force_shutdown(tp->t_mountp,
340344
SHUTDOWN_META_IO_ERROR);
345+
/* bad CRC means corrupted metadata */
346+
if (error == EFSBADCRC)
347+
error = EFSCORRUPTED;
341348
return error;
342349
}
343350
}
@@ -375,6 +382,10 @@ xfs_trans_read_buf_map(
375382
if (tp->t_flags & XFS_TRANS_DIRTY)
376383
xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR);
377384
xfs_buf_relse(bp);
385+
386+
/* bad CRC means corrupted metadata */
387+
if (error == EFSBADCRC)
388+
error = EFSCORRUPTED;
378389
return error;
379390
}
380391
#ifdef DEBUG

0 commit comments

Comments
 (0)