From: Darrick J. Wong Date: Thu, 5 Jul 2018 20:16:04 +0000 (-0500) Subject: xfs: fix off-by-one error in xfs_rtalloc_query_range X-Git-Tag: v4.18.0-rc0~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a4b61d98d4deef0c7cad6c0f349cf68935ee4055;p=thirdparty%2Fxfsprogs-dev.git xfs: fix off-by-one error in xfs_rtalloc_query_range Source kernel commit: a3a374bf1889b1b401b25e6aada3ca4151a99d15 In commit 8ad560d2565e6 ("xfs: strengthen rtalloc query range checks") we strengthened the input parameter checks in the rtbitmap range query function, but introduced an off-by-one error in the process. The call to xfs_rtfind_forw deals with the high key being rextents, but we clamp the high key to rextents - 1. This causes the returned results to stop one block short of the end of the rtdev, which is incorrect. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c index 766ae8cdc..e2f05cf59 100644 --- a/libxfs/xfs_rtbitmap.c +++ b/libxfs/xfs_rtbitmap.c @@ -1024,8 +1024,8 @@ xfs_rtalloc_query_range( if (low_rec->ar_startext >= mp->m_sb.sb_rextents || low_rec->ar_startext == high_rec->ar_startext) return 0; - if (high_rec->ar_startext >= mp->m_sb.sb_rextents) - high_rec->ar_startext = mp->m_sb.sb_rextents - 1; + if (high_rec->ar_startext > mp->m_sb.sb_rextents) + high_rec->ar_startext = mp->m_sb.sb_rextents; /* Iterate the bitmap, looking for discrepancies. */ rtstart = low_rec->ar_startext;