Skip to content

Commit acd1ac3

Browse files
committed
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: 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>
1 parent 74f4d6a commit acd1ac3

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fs/xfs/xfs_fsmap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ xfs_getfsmap_helper(
256256

257257
/* Are we just counting mappings? */
258258
if (info->head->fmh_count == 0) {
259+
if (info->head->fmh_entries == UINT_MAX)
260+
return -ECANCELED;
261+
259262
if (rec_daddr > info->next_daddr)
260263
info->head->fmh_entries++;
261264

0 commit comments

Comments
 (0)