aboutsummaryrefslogtreecommitdiff
path: root/fs/ntfs3
diff options
context:
space:
mode:
authorGravatar Konstantin Komarov <almaz.alexandrovich@paragon-software.com> 2021-10-25 18:34:06 +0300
committerGravatar Konstantin Komarov <almaz.alexandrovich@paragon-software.com> 2021-11-24 15:13:27 +0300
commit114346978cf61de02832cc3cc68432a3de70fb38 (patch)
treee42c3549de1a20930cf563c89712e4bab798cd9a /fs/ntfs3
parentfs/ntfs3: Fix fiemap + fix shrink file size (to remove preallocated space) (diff)
downloadlinux-114346978cf61de02832cc3cc68432a3de70fb38.tar.gz
linux-114346978cf61de02832cc3cc68432a3de70fb38.tar.bz2
linux-114346978cf61de02832cc3cc68432a3de70fb38.zip
fs/ntfs3: Check new size for limits
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>
Diffstat (limited to 'fs/ntfs3')
-rw-r--r--fs/ntfs3/file.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 6242708980d0..f8360f9bfaf0 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;