]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitb860843dcb9d8f3a798a8230d737666bb527adfc
treed1cc685953f34fb61fff3b709b5f2dd590eaee5e
parentf2b90921a980f7cc7caeac0961171c7046e9280b
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