Skip to content

Commit

Permalink
xfs: limit entries returned when counting fsmap records
Browse files Browse the repository at this point in the history
[ Upstream commit acd1ac3 ]

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: e89c041 ("xfs: implement the GETFSMAP ioctl")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
djwong authored and gregkh committed Oct 29, 2020
1 parent 2577720 commit adc3e26
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/xfs/xfs_fsmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,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++;

Expand Down

0 comments on commit adc3e26

Please sign in to comment.