Commit af8c53c8 authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Theodore Ts'o

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: 0c9ec4be ("ext4: support GETFSMAP ioctls")
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Link: https://lore.kernel.org/r/20201001222148.GA49520@magnoliaSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent addd752c
...@@ -108,6 +108,9 @@ static int ext4_getfsmap_helper(struct super_block *sb, ...@@ -108,6 +108,9 @@ static int ext4_getfsmap_helper(struct super_block *sb,
/* Are we just counting mappings? */ /* Are we just counting mappings? */
if (info->gfi_head->fmh_count == 0) { 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) if (rec_fsblk > info->gfi_next_fsblk)
info->gfi_head->fmh_entries++; info->gfi_head->fmh_entries++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment