summaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2020-10-01 15:21:48 -0700
committerTheodore Ts'o <tytso@mit.edu>2020-10-18 10:37:13 -0400
commitaf8c53c8bc087459b1aadd4c94805d8272358d79 (patch)
treefc3cf9709f023badf83b48cf536dab748d749dc2 /fs/ext4
parentaddd752cff27774258f593c68d283725398689c4 (diff)
downloadlinux-af8c53c8bc087459b1aadd4c94805d8272358d79.tar.gz
linux-af8c53c8bc087459b1aadd4c94805d8272358d79.tar.bz2
linux-af8c53c8bc087459b1aadd4c94805d8272358d79.zip
ext4: limit entries returned when counting fsmap records
If userspace asked fsmap to try 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: 0c9ec4beecac ("ext4: support GETFSMAP ioctls") Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Link: https://lore.kernel.org/r/20201001222148.GA49520@magnolia Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/fsmap.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c
index 005c0ae95a0e..b232c2767534 100644
--- a/fs/ext4/fsmap.c
+++ b/fs/ext4/fsmap.c
@@ -108,6 +108,9 @@ static int ext4_getfsmap_helper(struct super_block *sb,
/* Are we just counting mappings? */
if (info->gfi_head->fmh_count == 0) {
+ if (info->gfi_head->fmh_entries == UINT_MAX)
+ return EXT4_QUERY_RANGE_ABORT;
+
if (rec_fsblk > info->gfi_next_fsblk)
info->gfi_head->fmh_entries++;