]> git.baikalelectronics.ru Git - kernel.git/commit
ext4: fix fallocate to use file_modified to update permissions consistently
authorDarrick J. Wong <djwong@kernel.org>
Tue, 8 Mar 2022 18:50:43 +0000 (10:50 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 13 Apr 2022 02:22:02 +0000 (22:22 -0400)
commit9160fc9ea26c09cb1fd472da9de81c8f2fd050e5
tree327d0219545bfb055b6af9985bdf9194361e2112
parent97a8a6efd3987112b50f908bc2852408cbbc86ec
ext4: fix fallocate to use file_modified to update permissions consistently

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.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20220308185043.GA117678@magnolia
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/inode.c