Commit d53471ba authored by Amir Goldstein's avatar Amir Goldstein Committed by Christian Brauner

splice: remove permission hook from iter_file_splice_write()

All the callers of ->splice_write(), (e.g. do_splice_direct() and
do_splice()) already check rw_verify_area() for the entire range
and perform all the other checks that are in vfs_write_iter().

Instead of creating another tiny helper for special caller, just
open-code it.

This is needed for fanotify "pre content" events.
Suggested-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Link: https://lore.kernel.org/r/20231122122715.2561213-6-amir73il@gmail.comSigned-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent b70d8e2b
...@@ -673,10 +673,13 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out, ...@@ -673,10 +673,13 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
.u.file = out, .u.file = out,
}; };
int nbufs = pipe->max_usage; int nbufs = pipe->max_usage;
struct bio_vec *array = kcalloc(nbufs, sizeof(struct bio_vec), struct bio_vec *array;
GFP_KERNEL);
ssize_t ret; ssize_t ret;
if (!out->f_op->write_iter)
return -EINVAL;
array = kcalloc(nbufs, sizeof(struct bio_vec), GFP_KERNEL);
if (unlikely(!array)) if (unlikely(!array))
return -ENOMEM; return -ENOMEM;
...@@ -684,6 +687,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out, ...@@ -684,6 +687,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
splice_from_pipe_begin(&sd); splice_from_pipe_begin(&sd);
while (sd.total_len) { while (sd.total_len) {
struct kiocb kiocb;
struct iov_iter from; struct iov_iter from;
unsigned int head, tail, mask; unsigned int head, tail, mask;
size_t left; size_t left;
...@@ -733,7 +737,10 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out, ...@@ -733,7 +737,10 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
} }
iov_iter_bvec(&from, ITER_SOURCE, array, n, sd.total_len - left); iov_iter_bvec(&from, ITER_SOURCE, array, n, sd.total_len - left);
ret = vfs_iter_write(out, &from, &sd.pos, 0); init_sync_kiocb(&kiocb, out);
kiocb.ki_pos = sd.pos;
ret = call_write_iter(out, &kiocb, &from);
sd.pos = kiocb.ki_pos;
if (ret <= 0) if (ret <= 0)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment