]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
f2fs: do not allow partial truncation on pinned file
authorJaegeuk Kim <jaegeuk@kernel.org>
Sat, 8 Jan 2022 04:08:45 +0000 (20:08 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Jun 2024 11:39:36 +0000 (13:39 +0200)
[ Upstream commit 5fed0be8583f08c1548b4dcd9e5ee0d1133d0730 ]

If the pinned file has a hole by partial truncation, application that has
the block map will be broken.

Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Stable-dep-of: 278a6253a673 ("f2fs: fix to relocate check condition in f2fs_fallocate()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/file.c

index da071ed11a3f64161df601fee1d00d2d78af1237..959e1458412df0418f29fdb47d09a7aa56ff4559 100644 (file)
@@ -1760,7 +1760,11 @@ static long f2fs_fallocate(struct file *file, int mode,
                (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
                return -EOPNOTSUPP;
 
-       if (f2fs_compressed_file(inode) &&
+       /*
+        * Pinned file should not support partial trucation since the block
+        * can be used by applications.
+        */
+       if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) &&
                (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE |
                        FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE)))
                return -EOPNOTSUPP;