diff mbox series

[3/4] fs/ntfs3: Check new size for limits

Message ID 512a989d-c15f-d73f-09c1-74ba25eeec27@paragon-software.com (mailing list archive)
State New, archived
Headers show
Series fs/ntfs3: Various fixes for xfstests problems | expand

Commit Message

Konstantin Komarov Oct. 25, 2021, 4:59 p.m. UTC
We must check size before trying to allocate.
Size can be set for example by "ulimit -f".
Fixes xfstest generic/228
Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/file.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Kari Argillander Oct. 26, 2021, 9:22 p.m. UTC | #1
On Mon, Oct 25, 2021 at 07:59:26PM +0300, Konstantin Komarov wrote:
> We must check size before trying to allocate.
> Size can be set for example by "ulimit -f".
> Fixes xfstest generic/228

generic/228		[21:20:39][   18.058334] run fstests generic/228 at 2021-10-26 21:20:39
 [21:20:41] 2s
Ran: generic/228
Passed all 1 tests

> Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
> 
> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>

Reviewed-by: Kari Argillander <kari.argillander@gmail.com>

> ---
>  fs/ntfs3/file.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
> index 5418e5ba64b3..efb3110e1790 100644
> --- a/fs/ntfs3/file.c
> +++ b/fs/ntfs3/file.c
> @@ -661,7 +661,13 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
>  		/*
>  		 * Normal file: Allocate clusters, do not change 'valid' size.
>  		 */
> -		err = ntfs_set_size(inode, max(end, i_size));
> +		loff_t new_size = max(end, i_size);
> +
> +		err = inode_newsize_ok(inode, new_size);
> +		if (err)
> +			goto out;
> +
> +		err = ntfs_set_size(inode, new_size);
>  		if (err)
>  			goto out;
>  
> -- 
> 2.33.0
> 
>
diff mbox series

Patch

diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 5418e5ba64b3..efb3110e1790 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -661,7 +661,13 @@  static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
 		/*
 		 * Normal file: Allocate clusters, do not change 'valid' size.
 		 */
-		err = ntfs_set_size(inode, max(end, i_size));
+		loff_t new_size = max(end, i_size);
+
+		err = inode_newsize_ok(inode, new_size);
+		if (err)
+			goto out;
+
+		err = ntfs_set_size(inode, new_size);
 		if (err)
 			goto out;