[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YkW9+AK2d3i8X9rq@mit.edu>
Date: Thu, 31 Mar 2022 10:43:04 -0400
From: "Theodore Ts'o" <tytso@....edu>
To: Tadeusz Struk <tadeusz.struk@...aro.org>
Cc: Andreas Dilger <adilger.kernel@...ger.ca>,
Ritesh Harjani <riteshh@...ux.ibm.com>,
linux-ext4@...r.kernel.org, stable@...r.kernel.org,
linux-kernel@...r.kernel.org,
syzbot+7a806094edd5d07ba029@...kaller.appspotmail.com
Subject: Re: [PATCH v2] ext4: check if offset+length is valid in fallocate
On Tue, Mar 15, 2022 at 02:54:39PM -0700, Tadeusz Struk wrote:
> @@ -3967,6 +3968,16 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
> offset;
> }
>
> + /*
> + * For punch hole the length + offset needs to be at least within
> + * one block before last
> + */
> + max_length = sbi->s_bitmap_maxbytes - inode->i_sb->s_blocksize;
> + if (offset + length >= max_length) {
> + ret = -ENOSPC;
> + goto out_mutex;
> + }
I wonder if we would be better off just simply capping length to
max_length? If length is set to some large value, such as LONG_MAX,
it's pretty clear what the intention should be, which is to simply do
the equivalent of truncating the file at offset. Perhaps we should
just do that?
That being said, we should be consistent with what other file systems
do when they are asked to punch a hole starting at offset and
extending out to LONG_MAX.
Also, if we are going to return an error, I don't think ENOSPC is the
correct error to be returning.
- Ted
Powered by blists - more mailing lists