aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_rtbitmap.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-05-31 12:07:21 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2018-06-01 12:00:16 -0400
commit8ad560d2565e64b8be0cf5901c1e8fe034ac5599 (patch)
treea137e6d45738351525fba7e4852d55721214e88b /fs/xfs/libxfs/xfs_rtbitmap.c
parenta03f1641c7a6d4e88c6aae0cd3d52305cdb967a0 (diff)
xfs: strengthen rtalloc query range checks
Strengthen the rtalloc range query checks to make sure that the keys do not run off the end of the realtime device inappropriately. Note that the query range functions require units of rt extents, not blocks, despite the type name. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Allison Henderson <allison.henderson@oracle.com> Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_rtbitmap.c')
-rw-r--r--fs/xfs/libxfs/xfs_rtbitmap.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index 7712f282d172..1855182c11ec 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -1038,8 +1038,11 @@ xfs_rtalloc_query_range(
1038 1038
1039 if (low_rec->ar_startblock > high_rec->ar_startblock) 1039 if (low_rec->ar_startblock > high_rec->ar_startblock)
1040 return -EINVAL; 1040 return -EINVAL;
1041 else if (low_rec->ar_startblock == high_rec->ar_startblock) 1041 if (low_rec->ar_startblock >= mp->m_sb.sb_rextents ||
1042 low_rec->ar_startblock == high_rec->ar_startblock)
1042 return 0; 1043 return 0;
1044 if (high_rec->ar_startblock >= mp->m_sb.sb_rextents)
1045 high_rec->ar_startblock = mp->m_sb.sb_rextents - 1;
1043 1046
1044 /* Iterate the bitmap, looking for discrepancies. */ 1047 /* Iterate the bitmap, looking for discrepancies. */
1045 rtstart = low_rec->ar_startblock; 1048 rtstart = low_rec->ar_startblock;
@@ -1083,7 +1086,7 @@ xfs_rtalloc_query_all(
1083 struct xfs_rtalloc_rec keys[2]; 1086 struct xfs_rtalloc_rec keys[2];
1084 1087
1085 keys[0].ar_startblock = 0; 1088 keys[0].ar_startblock = 0;
1086 keys[1].ar_startblock = tp->t_mountp->m_sb.sb_rblocks; 1089 keys[1].ar_startblock = tp->t_mountp->m_sb.sb_rextents - 1;
1087 keys[0].ar_blockcount = keys[1].ar_blockcount = 0; 1090 keys[0].ar_blockcount = keys[1].ar_blockcount = 0;
1088 1091
1089 return xfs_rtalloc_query_range(tp, &keys[0], &keys[1], fn, priv); 1092 return xfs_rtalloc_query_range(tp, &keys[0], &keys[1], fn, priv);