summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2020-10-01 10:56:07 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-29 09:55:17 +0100
commit56c37c5dba2ce51e67167a6c4545f230a23607b9 (patch)
tree16e0aa29d2f5e41cc7aee777a16a75d5a9488615 /fs
parent3882d3641aff02002cc5c9570b0dd99f9685063c (diff)
downloadlinux-stable-56c37c5dba2ce51e67167a6c4545f230a23607b9.tar.gz
linux-stable-56c37c5dba2ce51e67167a6c4545f230a23607b9.tar.bz2
linux-stable-56c37c5dba2ce51e67167a6c4545f230a23607b9.zip
xfs: limit entries returned when counting fsmap records
[ Upstream commit acd1ac3aa22fd58803a12d26b1ab7f70232f8d8d ] 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> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_fsmap.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
index 3d76a9e35870..75b57b683d3e 100644
--- a/fs/xfs/xfs_fsmap.c
+++ b/fs/xfs/xfs_fsmap.c
@@ -259,6 +259,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++;