Commit 8ad560d2 authored by Darrick J. Wong's avatar Darrick J. Wong

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: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarAllison Henderson <allison.henderson@oracle.com>
Reviewed-by: default avatarBill O'Donnell <billodo@redhat.com>
parent a03f1641
...@@ -1038,8 +1038,11 @@ xfs_rtalloc_query_range( ...@@ -1038,8 +1038,11 @@ xfs_rtalloc_query_range(
if (low_rec->ar_startblock > high_rec->ar_startblock) if (low_rec->ar_startblock > high_rec->ar_startblock)
return -EINVAL; return -EINVAL;
else if (low_rec->ar_startblock == high_rec->ar_startblock) if (low_rec->ar_startblock >= mp->m_sb.sb_rextents ||
low_rec->ar_startblock == high_rec->ar_startblock)
return 0; return 0;
if (high_rec->ar_startblock >= mp->m_sb.sb_rextents)
high_rec->ar_startblock = mp->m_sb.sb_rextents - 1;
/* Iterate the bitmap, looking for discrepancies. */ /* Iterate the bitmap, looking for discrepancies. */
rtstart = low_rec->ar_startblock; rtstart = low_rec->ar_startblock;
...@@ -1083,7 +1086,7 @@ xfs_rtalloc_query_all( ...@@ -1083,7 +1086,7 @@ xfs_rtalloc_query_all(
struct xfs_rtalloc_rec keys[2]; struct xfs_rtalloc_rec keys[2];
keys[0].ar_startblock = 0; keys[0].ar_startblock = 0;
keys[1].ar_startblock = tp->t_mountp->m_sb.sb_rblocks; keys[1].ar_startblock = tp->t_mountp->m_sb.sb_rextents - 1;
keys[0].ar_blockcount = keys[1].ar_blockcount = 0; keys[0].ar_blockcount = keys[1].ar_blockcount = 0;
return xfs_rtalloc_query_range(tp, &keys[0], &keys[1], fn, priv); return xfs_rtalloc_query_range(tp, &keys[0], &keys[1], fn, priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment