From 40734dab5b1e6c5b9fea3a1df38d0b1a104b5d1f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 17 Oct 2021 11:08:26 +0200 Subject: [PATCH] 5.4-stable patches added patches: ovl-simplify-file-splice.patch --- queue-5.4/ovl-simplify-file-splice.patch | 89 ++++++++++++++++++++++++ queue-5.4/series | 1 + 2 files changed, 90 insertions(+) create mode 100644 queue-5.4/ovl-simplify-file-splice.patch create mode 100644 queue-5.4/series diff --git a/queue-5.4/ovl-simplify-file-splice.patch b/queue-5.4/ovl-simplify-file-splice.patch new file mode 100644 index 00000000000..64dd774d010 --- /dev/null +++ b/queue-5.4/ovl-simplify-file-splice.patch @@ -0,0 +1,89 @@ +From 82a763e61e2b601309d696d4fa514c77d64ee1be Mon Sep 17 00:00:00 2001 +From: Miklos Szeredi +Date: Mon, 14 Dec 2020 15:26:14 +0100 +Subject: ovl: simplify file splice + +From: Miklos Szeredi + +commit 82a763e61e2b601309d696d4fa514c77d64ee1be upstream. + +generic_file_splice_read() and iter_file_splice_write() will call back into +f_op->iter_read() and f_op->iter_write() respectively. These already do +the real file lookup and cred override. So the code in ovl_splice_read() +and ovl_splice_write() is redundant. + +In addition the ovl_file_accessed() call in ovl_splice_write() is +incorrect, though probably harmless. + +Fix by calling generic_file_splice_read() and iter_file_splice_write() +directly. + +Signed-off-by: Miklos Szeredi +[reported to resolve issues with 1a980b8cbf00 ("ovl: add splice file read write helper")] +Signed-off-by: Greg Kroah-Hartman +--- + fs/overlayfs/file.c | 46 ++-------------------------------------------- + 1 file changed, 2 insertions(+), 44 deletions(-) + +--- a/fs/overlayfs/file.c ++++ b/fs/overlayfs/file.c +@@ -296,48 +296,6 @@ out_unlock: + return ret; + } + +-static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, +- struct pipe_inode_info *pipe, size_t len, +- unsigned int flags) +-{ +- ssize_t ret; +- struct fd real; +- const struct cred *old_cred; +- +- ret = ovl_real_fdget(in, &real); +- if (ret) +- return ret; +- +- old_cred = ovl_override_creds(file_inode(in)->i_sb); +- ret = generic_file_splice_read(real.file, ppos, pipe, len, flags); +- revert_creds(old_cred); +- +- ovl_file_accessed(in); +- fdput(real); +- return ret; +-} +- +-static ssize_t +-ovl_splice_write(struct pipe_inode_info *pipe, struct file *out, +- loff_t *ppos, size_t len, unsigned int flags) +-{ +- struct fd real; +- const struct cred *old_cred; +- ssize_t ret; +- +- ret = ovl_real_fdget(out, &real); +- if (ret) +- return ret; +- +- old_cred = ovl_override_creds(file_inode(out)->i_sb); +- ret = iter_file_splice_write(pipe, real.file, ppos, len, flags); +- revert_creds(old_cred); +- +- ovl_file_accessed(out); +- fdput(real); +- return ret; +-} +- + static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) + { + struct fd real; +@@ -694,8 +652,8 @@ const struct file_operations ovl_file_op + .fadvise = ovl_fadvise, + .unlocked_ioctl = ovl_ioctl, + .compat_ioctl = ovl_compat_ioctl, +- .splice_read = ovl_splice_read, +- .splice_write = ovl_splice_write, ++ .splice_read = generic_file_splice_read, ++ .splice_write = iter_file_splice_write, + + .copy_file_range = ovl_copy_file_range, + .remap_file_range = ovl_remap_file_range, diff --git a/queue-5.4/series b/queue-5.4/series new file mode 100644 index 00000000000..db9e05b74b7 --- /dev/null +++ b/queue-5.4/series @@ -0,0 +1 @@ +ovl-simplify-file-splice.patch -- 2.47.3