summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2022-05-17 11:37:23 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-09 10:23:18 +0200
commit59f42b4150022f216a4e92bbf672ef2bc9c413c8 (patch)
tree7c2fdad3487c3e405865c428febd3a18b7248888 /fs/f2fs
parent6bde47f4e81344f43514408f8ba799e8c2b090e8 (diff)
downloadlinux-stable-59f42b4150022f216a4e92bbf672ef2bc9c413c8.tar.gz
linux-stable-59f42b4150022f216a4e92bbf672ef2bc9c413c8.tar.bz2
linux-stable-59f42b4150022f216a4e92bbf672ef2bc9c413c8.zip
f2fs: fix fallocate to use file_modified to update permissions consistently
commit 958ed92922028ec67f504dcdc72bfdfd0f43936a upstream. This patch tries to fix permission consistency issue as all other mainline filesystems. Since the initial introduction of (posix) fallocate back at the turn of the century, it has been possible to use this syscall to change the user-visible contents of files. This can happen by extending the file size during a preallocation, or through any of the newer modes (punch, zero, collapse, insert range). Because the call can be used to change file contents, we should treat it like we do any other modification to a file -- update the mtime, and drop set[ug]id privileges/capabilities. The VFS function file_modified() does all this for us if pass it a locked inode, so let's make fallocate drop permissions correctly. Cc: stable@kernel.org Signed-off-by: Chao Yu <chao.yu@oppo.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 9119950cb762..c67756a6e32a 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1768,6 +1768,10 @@ static long f2fs_fallocate(struct file *file, int mode,
inode_lock(inode);
+ ret = file_modified(file);
+ if (ret)
+ goto out;
+
if (mode & FALLOC_FL_PUNCH_HOLE) {
if (offset >= inode->i_size)
goto out;