From: Darrick J. Wong Date: Thu, 28 Jun 2018 20:11:57 +0000 (-0500) Subject: xfs: xfs_rtbuf_get should check the bmapi_read results X-Git-Tag: v4.18.0-rc0~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e28c9c80acc4ef2dbf25853e4c18fec258779ce;p=thirdparty%2Fxfsprogs-dev.git xfs: xfs_rtbuf_get should check the bmapi_read results Source kernel commit: a03f1641c7a6d4e88c6aae0cd3d52305cdb967a0 The xfs_rtbuf_get function should check the block mapping it gets back from bmapi_read. If there are no mappings or the mapping isn't a real extent, we should return -EFSCORRUPTED rather than trying to read a garbage value. We also require realtime bitmap blocks to be real, written allocations. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Bill O'Donnell Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index cf04ccac4..652eb4f69 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -85,6 +85,9 @@ xfs_rtbuf_get( if (error) return error; + if (nmap == 0 || !xfs_bmap_is_real_extent(&map)) + return -EFSCORRUPTED; + ASSERT(map.br_startblock != NULLFSBLOCK); error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, XFS_FSB_TO_DADDR(mp, map.br_startblock),