Commit acd1ac3a authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: limit entries returned when counting fsmap records



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: e89c0413 ("xfs: implement the GETFSMAP ioctl")
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChandan Babu R <chandanrlinux@gmail.com>
parent 74f4d6a1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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++;