btrfs: fix fallocate to use file_modified to update permissions consistently
authorDarrick J. Wong <djwong@kernel.org>
Mon, 14 Mar 2022 17:55:32 +0000 (10:55 -0700)
committerDavid Sterba <dsterba@suse.com>
Thu, 24 Mar 2022 16:48:02 +0000 (17:48 +0100)
commit05fd9564e9faf0f23b4676385e27d9405cef6637
treed1cc685953f34fb61fff3b709b5f2dd590eaee5e
parentbbac58698a55cc0a6f0c0d69a6dcd3f9f3134c11
btrfs: 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 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.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c