]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
f2fs: reject setattr size changes on large folio files
authorWenjie Qi <qwjhust@gmail.com>
Wed, 10 Jun 2026 14:37:35 +0000 (22:37 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 22 Jun 2026 19:52:37 +0000 (19:52 +0000)
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>
fs/f2fs/file.c

index 69aad1060c487b52de3f1d78b85c2ad9413038b8..d240ca78a31fe6238f7e3f1ad35826c455d61c76 100644 (file)
@@ -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;