]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs/ntfs3: Check new size for limits
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Mon, 25 Oct 2021 15:34:06 +0000 (18:34 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:29:28 +0000 (10:29 +0200)
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 <kari.argillander@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ntfs3/file.c

index 1eb5d88e661c79ecb3307ad9404ebb16c2e3532a..3bae76930e68a012a00df9f35cc15cc3b35be1d6 100644 (file)
@@ -662,7 +662,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;