From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Chao Yu <chao@kernel.org>
Subject: [PATCH] f2fs: fix to prevent clearing immutable for large folio supported inode
Date: Fri, 9 Jan 2026 10:47:16 +0800 [thread overview]
Message-ID: <20260109024716.12047-1-chao@kernel.org> (raw)
Below testcase can change large folio supported inode from immutable
to mutable, it's not as expected, let's add a new check condition in
f2fs_setflags_common() to detect and reject it.
- dd if=/dev/zero of=/mnt/f2fs/test bs=32k count=4
- f2fs_io setflags immutable /mnt/f2fs/test
- echo 3 > /proc/sys/vm/drop_caches
: to reload inode with large folio
- f2fs_io read 32 0 1 mmap 0 0 /mnt/f2fs/test
- f2fs_io clearflags immutable /mnt/f2fs/test
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/file.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ce291f152bc3..f7f9da0b215f 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2155,6 +2155,12 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
}
}
+ if ((iflags ^ masked_flags) & F2FS_IMMUTABLE_FL) {
+ if ((masked_flags & F2FS_IMMUTABLE_FL) &&
+ mapping_large_folio_support(inode->i_mapping))
+ return -EINVAL;
+ }
+
fi->i_flags = iflags | (fi->i_flags & ~mask);
f2fs_bug_on(F2FS_I_SB(inode), (fi->i_flags & F2FS_COMPR_FL) &&
(fi->i_flags & F2FS_NOCOMP_FL));
--
2.40.1
next reply other threads:[~2026-01-09 2:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 2:47 Chao Yu [this message]
2026-01-09 3:05 ` [PATCH] f2fs: fix to prevent clearing immutable for large folio supported inode Barry Song
2026-01-09 3:45 ` Chao Yu
2026-01-09 3:57 ` Barry Song
2026-01-09 8:44 ` Chao Yu
2026-01-22 2:02 ` [f2fs-dev] " Nanzhe Zhao
2026-01-22 23:10 ` Jaegeuk Kim
2026-01-23 6:30 ` Nanzhe Zhao
2026-02-24 3:55 ` Jaegeuk Kim
2026-01-23 4:04 ` Chao Yu
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=20260109024716.12047-1-chao@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox