diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2020-10-01 10:56:07 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-29 10:11:40 +0100 |
commit | afd372962899aa95c8a36cebf7aa75b4193e6a28 (patch) | |
tree | 0806efba097cc81a9b345f0c5ed7aa08fc9b8450 /fs | |
parent | cc3a03c9c13e7f089866c34e4fa06ffc53d5c9ec (diff) | |
download | linux-stable-afd372962899aa95c8a36cebf7aa75b4193e6a28.tar.gz linux-stable-afd372962899aa95c8a36cebf7aa75b4193e6a28.tar.bz2 linux-stable-afd372962899aa95c8a36cebf7aa75b4193e6a28.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.c | 3 |
1 files changed, 3 insertions, 0 deletions
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++; |