* [PATCH] f2fs: reject setattr writes on large folio files
@ 2026-05-21 11:05 ` Wenjie Qi
0 siblings, 0 replies; 4+ messages in thread
From: Wenjie Qi @ 2026-05-21 11:05 UTC (permalink / raw)
To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, qiwenjie, qwjhust
F2FS large folio support is read-only. It rejects writable opens and
mmap writes when an inode mapping supports large folios, but setattr can
still reach the inode without going through those checks.
For immutable large-folio files, clearing the immutable flag keeps the
cached inode and its large-folio mapping alive until the inode is
dropped. A path-based truncate(2) can then call f2fs_setattr() with
ATTR_SIZE and change the file size without opening the file for write.
The user.fadvise path adds another visible case: after the file is
reopened with large folios, chmod(WRITE) is documented to fail, but
f2fs_setattr() currently allows ATTR_MODE to add write bits back.
Reject size changes and mode changes that enable write permissions while
the mapping still supports large folios. Read-only mode changes and
unrelated metadata updates remain allowed.
Fixes: 05e65c14ea59 ("f2fs: support large folio for immutable non-compressed case")
Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
---
fs/f2fs/file.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 71385ca4163d..3880ff5e6740 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1097,6 +1097,11 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
ATTR_GID | ATTR_TIMES_SET))))
return -EPERM;
+ if (mapping_large_folio_support(inode->i_mapping) &&
+ ((attr->ia_valid & ATTR_SIZE) ||
+ ((attr->ia_valid & ATTR_MODE) && (attr->ia_mode & 0222))))
+ return -EOPNOTSUPP;
+
if ((attr->ia_valid & ATTR_SIZE)) {
if (!f2fs_is_compress_backend_ready(inode) ||
IS_DEVICE_ALIASING(inode))
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [f2fs-dev] [PATCH] f2fs: reject setattr writes on large folio files
@ 2026-05-21 11:05 ` Wenjie Qi
0 siblings, 0 replies; 4+ messages in thread
From: Wenjie Qi @ 2026-05-21 11:05 UTC (permalink / raw)
To: jaegeuk, chao; +Cc: qwjhust, qiwenjie, linux-kernel, linux-f2fs-devel
F2FS large folio support is read-only. It rejects writable opens and
mmap writes when an inode mapping supports large folios, but setattr can
still reach the inode without going through those checks.
For immutable large-folio files, clearing the immutable flag keeps the
cached inode and its large-folio mapping alive until the inode is
dropped. A path-based truncate(2) can then call f2fs_setattr() with
ATTR_SIZE and change the file size without opening the file for write.
The user.fadvise path adds another visible case: after the file is
reopened with large folios, chmod(WRITE) is documented to fail, but
f2fs_setattr() currently allows ATTR_MODE to add write bits back.
Reject size changes and mode changes that enable write permissions while
the mapping still supports large folios. Read-only mode changes and
unrelated metadata updates remain allowed.
Fixes: 05e65c14ea59 ("f2fs: support large folio for immutable non-compressed case")
Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
---
fs/f2fs/file.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 71385ca4163d..3880ff5e6740 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1097,6 +1097,11 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
ATTR_GID | ATTR_TIMES_SET))))
return -EPERM;
+ if (mapping_large_folio_support(inode->i_mapping) &&
+ ((attr->ia_valid & ATTR_SIZE) ||
+ ((attr->ia_valid & ATTR_MODE) && (attr->ia_mode & 0222))))
+ return -EOPNOTSUPP;
+
if ((attr->ia_valid & ATTR_SIZE)) {
if (!f2fs_is_compress_backend_ready(inode) ||
IS_DEVICE_ALIASING(inode))
--
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: reject setattr writes on large folio files
2026-05-21 11:05 ` [f2fs-dev] " Wenjie Qi
@ 2026-06-10 0:26 ` Jaegeuk Kim
-1 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2026-06-10 0:26 UTC (permalink / raw)
To: Wenjie Qi; +Cc: linux-f2fs-devel, qiwenjie, linux-kernel
On 05/21, Wenjie Qi wrote:
> F2FS large folio support is read-only. It rejects writable opens and
> mmap writes when an inode mapping supports large folios, but setattr can
> still reach the inode without going through those checks.
>
> For immutable large-folio files, clearing the immutable flag keeps the
> cached inode and its large-folio mapping alive until the inode is
> dropped. A path-based truncate(2) can then call f2fs_setattr() with
> ATTR_SIZE and change the file size without opening the file for write.
>
> The user.fadvise path adds another visible case: after the file is
> reopened with large folios, chmod(WRITE) is documented to fail, but
> f2fs_setattr() currently allows ATTR_MODE to add write bits back.
We don't add this anymore. Can you update?
>
> Reject size changes and mode changes that enable write permissions while
> the mapping still supports large folios. Read-only mode changes and
> unrelated metadata updates remain allowed.
>
> Fixes: 05e65c14ea59 ("f2fs: support large folio for immutable non-compressed case")
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
> ---
> fs/f2fs/file.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 71385ca4163d..3880ff5e6740 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1097,6 +1097,11 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> ATTR_GID | ATTR_TIMES_SET))))
> return -EPERM;
>
> + if (mapping_large_folio_support(inode->i_mapping) &&
> + ((attr->ia_valid & ATTR_SIZE) ||
> + ((attr->ia_valid & ATTR_MODE) && (attr->ia_mode & 0222))))
> + return -EOPNOTSUPP;
> +
> if ((attr->ia_valid & ATTR_SIZE)) {
> if (!f2fs_is_compress_backend_ready(inode) ||
> IS_DEVICE_ALIASING(inode))
> --
> 2.43.0
>
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: reject setattr writes on large folio files
@ 2026-06-10 0:26 ` Jaegeuk Kim
0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2026-06-10 0:26 UTC (permalink / raw)
To: Wenjie Qi; +Cc: chao, qiwenjie, linux-kernel, linux-f2fs-devel
On 05/21, Wenjie Qi wrote:
> F2FS large folio support is read-only. It rejects writable opens and
> mmap writes when an inode mapping supports large folios, but setattr can
> still reach the inode without going through those checks.
>
> For immutable large-folio files, clearing the immutable flag keeps the
> cached inode and its large-folio mapping alive until the inode is
> dropped. A path-based truncate(2) can then call f2fs_setattr() with
> ATTR_SIZE and change the file size without opening the file for write.
>
> The user.fadvise path adds another visible case: after the file is
> reopened with large folios, chmod(WRITE) is documented to fail, but
> f2fs_setattr() currently allows ATTR_MODE to add write bits back.
We don't add this anymore. Can you update?
>
> Reject size changes and mode changes that enable write permissions while
> the mapping still supports large folios. Read-only mode changes and
> unrelated metadata updates remain allowed.
>
> Fixes: 05e65c14ea59 ("f2fs: support large folio for immutable non-compressed case")
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
> ---
> fs/f2fs/file.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 71385ca4163d..3880ff5e6740 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1097,6 +1097,11 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> ATTR_GID | ATTR_TIMES_SET))))
> return -EPERM;
>
> + if (mapping_large_folio_support(inode->i_mapping) &&
> + ((attr->ia_valid & ATTR_SIZE) ||
> + ((attr->ia_valid & ATTR_MODE) && (attr->ia_mode & 0222))))
> + return -EOPNOTSUPP;
> +
> if ((attr->ia_valid & ATTR_SIZE)) {
> if (!f2fs_is_compress_backend_ready(inode) ||
> IS_DEVICE_ALIASING(inode))
> --
> 2.43.0
>
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-10 0:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-21 11:05 [PATCH] f2fs: reject setattr writes on large folio files Wenjie Qi
2026-05-21 11:05 ` [f2fs-dev] " Wenjie Qi
2026-06-10 0:26 ` Jaegeuk Kim via Linux-f2fs-devel
2026-06-10 0:26 ` Jaegeuk Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.