* [PATCH] f2fs: reject immutable and append-only files in move range
@ 2026-11-17 17:37 Hungyu Lin
0 siblings, 0 replies; only message in thread
From: Hungyu Lin @ 2026-11-17 17:37 UTC (permalink / raw)
To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, dennylin0707
F2FS_IOC_MOVE_RANGE only checks that both files are open for writing. It
does not look at the inode flags, so it replaces blocks of the
destination file and punches blocks out of the source file even if the
file is append-only or immutable.
An append-only file can be opened for writing with O_APPEND, so a user
with write permission on such a file can overwrite or remove the data
that is already there, which ftruncate() and fallocate() do not allow.
For an immutable file the same works through a file descriptor that was
opened for writing before the flag was set, although f2fs_write_checks()
refuses writes through it.
Return -EPERM if either file is immutable or append-only.
Fixes: 4dd6f977fc77 ("f2fs: support an ioctl to move a range of data blocks")
Cc: stable@kernel.org
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
fs/f2fs/file.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index e2c0f5083313..9cf733954522 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3265,6 +3265,12 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
goto out;
}
+ if (IS_IMMUTABLE(src) || IS_APPEND(src) ||
+ IS_IMMUTABLE(dst) || IS_APPEND(dst)) {
+ ret = -EPERM;
+ goto out_unlock;
+ }
+
if (f2fs_compressed_file(src) || f2fs_compressed_file(dst) ||
f2fs_is_pinned_file(src) || f2fs_is_pinned_file(dst)) {
ret = -EOPNOTSUPP;
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-17 17:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 17:37 [PATCH] f2fs: reject immutable and append-only files in move range Hungyu Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®