All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Wenjie Qi <qwjhust@gmail.com>
Cc: linux-f2fs-devel@lists.sourceforge.net, qiwenjie@xiaomi.com,
	linux-kernel@vger.kernel.org
Subject: Re: [f2fs-dev] [PATCH] f2fs: reject setattr writes on large folio files
Date: Wed, 10 Jun 2026 00:26:53 +0000	[thread overview]
Message-ID: <aiivTdvRhZlk6wC3@google.com> (raw)
In-Reply-To: <20260521110526.1967583-1-qiwenjie@xiaomi.com>

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

WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Wenjie Qi <qwjhust@gmail.com>
Cc: chao@kernel.org, qiwenjie@xiaomi.com,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: reject setattr writes on large folio files
Date: Wed, 10 Jun 2026 00:26:53 +0000	[thread overview]
Message-ID: <aiivTdvRhZlk6wC3@google.com> (raw)
In-Reply-To: <20260521110526.1967583-1-qiwenjie@xiaomi.com>

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

  reply	other threads:[~2026-06-10  0:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-06-10  0:26   ` Jaegeuk Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aiivTdvRhZlk6wC3@google.com \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=jaegeuk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qiwenjie@xiaomi.com \
    --cc=qwjhust@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.