From: Konstantin Komarov Date: Mon, 25 Oct 2021 15:34:06 +0000 (+0300) Subject: fs/ntfs3: Check new size for limits X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f45bd2922d66b8195c7c22f19d918eb353cc05ef;p=linux.git fs/ntfs3: Check new size for limits commit 114346978cf61de02832cc3cc68432a3de70fb38 upstream. 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") Reviewed-by: Kari Argillander Signed-off-by: Konstantin Komarov Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index d7128be64cd61..7a678a5b1ca5f 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;