Message ID | 160161416467.1967459.10753396346204946090.stgit@magnolia (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xfs: a few fixes and cleanups to GETFSMAP | expand |
On Thu, Oct 01, 2020 at 09:49:24PM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong <darrick.wong@oracle.com> > > If userspace asked fsmap to count the number of entries, we cannot > return more than UINT_MAX entries because fmh_entries is u32. > Therefore, stop counting if we hit this limit or else we will waste time > to return truncated results. Looks good, Reviewed-by: Christoph Hellwig <hch@lst.de> (after remembering the magic repurposing of -ECANCELED in the fsmap code)
On Friday 2 October 2020 10:19:24 AM IST Darrick J. Wong wrote: > From: Darrick J. Wong <darrick.wong@oracle.com> > > If userspace asked fsmap to count the number of entries, we cannot > return more than UINT_MAX entries because fmh_entries is u32. > Therefore, stop counting if we hit this limit or else we will waste time > to return truncated results. > > Fixes: e89c041338ed ("xfs: implement the GETFSMAP ioctl") > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> The upper bound check is correct. Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com> > --- > fs/xfs/xfs_fsmap.c | 3 +++ > 1 file changed, 3 insertions(+) > > > diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c > index 4eebcec4aae6..aa36e7daf82c 100644 > --- a/fs/xfs/xfs_fsmap.c > +++ b/fs/xfs/xfs_fsmap.c > @@ -256,6 +256,9 @@ xfs_getfsmap_helper( > > /* Are we just counting mappings? */ > if (info->head->fmh_count == 0) { > + if (info->head->fmh_entries == UINT_MAX) > + return -ECANCELED; > + > if (rec_daddr > info->next_daddr) > info->head->fmh_entries++; > > >
diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c index 4eebcec4aae6..aa36e7daf82c 100644 --- a/fs/xfs/xfs_fsmap.c +++ b/fs/xfs/xfs_fsmap.c @@ -256,6 +256,9 @@ xfs_getfsmap_helper( /* Are we just counting mappings? */ if (info->head->fmh_count == 0) { + if (info->head->fmh_entries == UINT_MAX) + return -ECANCELED; + if (rec_daddr > info->next_daddr) info->head->fmh_entries++;