linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: limit entries returned when counting fsmap records
@ 2020-10-01 22:21 Darrick J. Wong
  2020-10-03  5:23 ` Theodore Y. Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2020-10-01 22:21 UTC (permalink / raw)
  To: Theodore Ts'o, linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

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>
---
 fs/ext4/fsmap.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c
index dbccf46f1770..37347ba868b7 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++;
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext4: limit entries returned when counting fsmap records
  2020-10-01 22:21 [PATCH] ext4: limit entries returned when counting fsmap records Darrick J. Wong
@ 2020-10-03  5:23 ` Theodore Y. Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Y. Ts'o @ 2020-10-03  5:23 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Thu, Oct 01, 2020 at 03:21:48PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> 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>

Applied, thanks.

					- Ted

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-03  5:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01 22:21 [PATCH] ext4: limit entries returned when counting fsmap records Darrick J. Wong
2020-10-03  5:23 ` Theodore Y. Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).