summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWenjie Qi <qwjhust@gmail.com>2026-06-10 22:37:35 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-04 13:45:05 +0200
commitf5b8b3dd6e8593262726147fb6bac4526b0cb0fb (patch)
treea5f018ca30c624b92ec339ebec92444e8072c2ec
parent8a2d8a34ef0bb669321ba411df5ee57975919e88 (diff)
downloadlinux-stable-f5b8b3dd6e8593262726147fb6bac4526b0cb0fb.tar.gz
linux-stable-f5b8b3dd6e8593262726147fb6bac4526b0cb0fb.zip
f2fs: reject setattr size changes on large folio files
commit 242d30bfc0a84b8b5de0a88821b53c9ad7fd31c4 upstream. F2FS large folios are only enabled for immutable non-compressed files. Writable open and writable mmap reject such mappings, but truncate(2) through f2fs_setattr() misses the same guard. If FS_IMMUTABLE_FL is cleared while the inode is still cached, the mapping can keep large-folio support and ATTR_SIZE can change i_size. Reject size changes in that state. Cc: stable@kernel.org Fixes: 05e65c14ea59 ("f2fs: support large folio for immutable non-compressed case") Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/f2fs/file.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index fb12c5c9affd..6d750e9d6f32 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1098,6 +1098,8 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
return -EPERM;
if ((attr->ia_valid & ATTR_SIZE)) {
+ if (mapping_large_folio_support(inode->i_mapping))
+ return -EOPNOTSUPP;
if (!f2fs_is_compress_backend_ready(inode) ||
IS_DEVICE_ALIASING(inode))
return -EOPNOTSUPP;