From: Darrick J. Wong Date: Fri, 1 May 2020 21:37:09 +0000 (-0400) Subject: xfs: fix buffer corruption reporting when xfs_dir3_free_header_check fails X-Git-Tag: v5.7.0-rc0~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=90d7e2ab9af5a2d47fb6bbf0611b4ee38651eb96;p=thirdparty%2Fxfsprogs-dev.git xfs: fix buffer corruption reporting when xfs_dir3_free_header_check fails Source kernel commit: ce99494c9699df58b31d0a839e957f86cd58c755 xfs_verifier_error is supposed to be called on a corrupt metadata buffer from within a buffer verifier function, whereas xfs_buf_mark_corrupt is the function to be called when a piece of code has read a buffer and catches something that a read verifier cannot. The first function sets b_error anticipating that the low level buffer handling code will see the nonzero b_error and clear XBF_DONE on the buffer, whereas the second function does not. Since xfs_dir3_free_header_check examines fields in the dir free block header that require more context than can be provided to read verifiers, we must call xfs_buf_mark_corrupt when it finds a problem. Switching the calls has a secondary effect that we no longer corrupt the buffer state by setting b_error and leaving XBF_DONE set. When /that/ happens, we'll trip over various state assertions (most commonly the b_error check in xfs_buf_reverify) on a subsequent attempt to read the buffer. Fixes: bc1a09b8e334bf5f ("xfs: refactor verifier callers to print address of failing check") Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c index 3dd999c3b..56eae67e7 100644 --- a/libxfs/xfs_dir2_node.c +++ b/libxfs/xfs_dir2_node.c @@ -223,7 +223,7 @@ __xfs_dir3_free_read( /* Check things that we can't do in the verifier. */ fa = xfs_dir3_free_header_check(dp, fbno, *bpp); if (fa) { - xfs_verifier_error(*bpp, -EFSCORRUPTED, fa); + __xfs_buf_mark_corrupt(*bpp, fa); xfs_trans_brelse(tp, *bpp); return -EFSCORRUPTED; }