]> 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)
commit52960144690483adefa2e90280a771c422278f4a
treed1cc685953f34fb61fff3b709b5f2dd590eaee5e
parentc37448c72cab213e8a8352e1b6e40c401943f876
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