Skip to content

Commit

Permalink
ext4: limit entries returned when counting fsmap records
Browse files Browse the repository at this point in the history
[ Upstream commit af8c53c ]

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: 0c9ec4b ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
djwong authored and gregkh committed Oct 29, 2020
1 parent 9ede401 commit 6d05906
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/ext4/fsmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;

Expand Down

0 comments on commit 6d05906

Please sign in to comment.