Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Jan Kara <jack@suse.cz>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Link: https://lore.kernel.org/r/20231122122715.2561213-6-amir73il@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Amir Goldstein and committed by
Christian Brauner
d53471ba b70d8e2b

+10 -3
+10 -3
fs/splice.c
··· 673 673 .u.file = out, 674 674 }; 675 675 int nbufs = pipe->max_usage; 676 - struct bio_vec *array = kcalloc(nbufs, sizeof(struct bio_vec), 677 - GFP_KERNEL); 676 + struct bio_vec *array; 678 677 ssize_t ret; 679 678 679 + if (!out->f_op->write_iter) 680 + return -EINVAL; 681 + 682 + array = kcalloc(nbufs, sizeof(struct bio_vec), GFP_KERNEL); 680 683 if (unlikely(!array)) 681 684 return -ENOMEM; 682 685 ··· 687 684 688 685 splice_from_pipe_begin(&sd); 689 686 while (sd.total_len) { 687 + struct kiocb kiocb; 690 688 struct iov_iter from; 691 689 unsigned int head, tail, mask; 692 690 size_t left; ··· 737 733 } 738 734 739 735 iov_iter_bvec(&from, ITER_SOURCE, array, n, sd.total_len - left); 740 - ret = vfs_iter_write(out, &from, &sd.pos, 0); 736 + init_sync_kiocb(&kiocb, out); 737 + kiocb.ki_pos = sd.pos; 738 + ret = call_write_iter(out, &kiocb, &from); 739 + sd.pos = kiocb.ki_pos; 741 740 if (ret <= 0) 742 741 break; 743 742