mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 13:41:51 +00:00
btrfs: move file_start_write() to after permission hook
In vfs code, file_start_write() is usually called after the permission hook in rw_verify_area(). btrfs_ioctl_encoded_write() in an exception to this rule. Move file_start_write() to after the rw_verify_area() check in encoded write to make the permission hook "start-write-safe". This is needed for fanotify "pre content" events. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://lore.kernel.org/r/20231122122715.2561213-9-amir73il@gmail.com Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
0b5263d12a
commit
2f4d8ad825
@ -4523,29 +4523,29 @@ static int btrfs_ioctl_encoded_write(struct file *file, void __user *argp, bool
|
||||
if (ret < 0)
|
||||
goto out_acct;
|
||||
|
||||
file_start_write(file);
|
||||
|
||||
if (iov_iter_count(&iter) == 0) {
|
||||
ret = 0;
|
||||
goto out_end_write;
|
||||
goto out_iov;
|
||||
}
|
||||
pos = args.offset;
|
||||
ret = rw_verify_area(WRITE, file, &pos, args.len);
|
||||
if (ret < 0)
|
||||
goto out_end_write;
|
||||
goto out_iov;
|
||||
|
||||
init_sync_kiocb(&kiocb, file);
|
||||
ret = kiocb_set_rw_flags(&kiocb, 0);
|
||||
if (ret)
|
||||
goto out_end_write;
|
||||
goto out_iov;
|
||||
kiocb.ki_pos = pos;
|
||||
|
||||
file_start_write(file);
|
||||
|
||||
ret = btrfs_do_write_iter(&kiocb, &iter, &args);
|
||||
if (ret > 0)
|
||||
fsnotify_modify(file);
|
||||
|
||||
out_end_write:
|
||||
file_end_write(file);
|
||||
out_iov:
|
||||
kfree(iov);
|
||||
out_acct:
|
||||
if (ret > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user