Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: fix fallocate to use file_modified to update permissions consistently

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>

authored by

Chao Yu and committed by
Jaegeuk Kim
958ed929 b5639bb4

+4
+4
fs/f2fs/file.c
··· 1780 1780 1781 1781 inode_lock(inode); 1782 1782 1783 + ret = file_modified(file); 1784 + if (ret) 1785 + goto out; 1786 + 1783 1787 if (mode & FALLOC_FL_PUNCH_HOLE) { 1784 1788 if (offset >= inode->i_size) 1785 1789 goto out;