* [PATCH] ovl: add splice file read write helper
@ 2021-08-20 19:59 Leah Rumancik
2021-08-21 11:29 ` Greg KH
2021-08-23 0:54 ` Sasha Levin
0 siblings, 2 replies; 3+ messages in thread
From: Leah Rumancik @ 2021-08-20 19:59 UTC (permalink / raw)
To: stable; +Cc: miklos, Murphy Zhou, Miklos Szeredi
From: Murphy Zhou <jencce.kernel@gmail.com>
Now overlayfs falls back to use default file splice read
and write, which is not compatiple with overlayfs, returning
EFAULT. xfstests generic/591 can reproduce part of this.
Tested this patch with xfstests auto group tests.
[ Needed in 5.4 to fix a deadlock triggered via
xfstests overlay/019 -- Leah Rumancik ]
Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/overlayfs/file.c | 47 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 7a08a576f7b2..ab5e92897270 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -9,6 +9,9 @@
#include <linux/xattr.h>
#include <linux/uio.h>
#include <linux/uaccess.h>
+#include <linux/splice.h>
+#include <linux/mm.h>
+#include <linux/fs.h>
#include "overlayfs.h"
static char ovl_whatisit(struct inode *inode, struct inode *realinode)
@@ -293,6 +296,48 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
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;
@@ -649,6 +694,8 @@ const struct file_operations ovl_file_operations = {
.fadvise = ovl_fadvise,
.unlocked_ioctl = ovl_ioctl,
.compat_ioctl = ovl_compat_ioctl,
+ .splice_read = ovl_splice_read,
+ .splice_write = ovl_splice_write,
.copy_file_range = ovl_copy_file_range,
.remap_file_range = ovl_remap_file_range,
--
2.33.0.rc2.250.ged5fa647cd-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ovl: add splice file read write helper
2021-08-20 19:59 [PATCH] ovl: add splice file read write helper Leah Rumancik
@ 2021-08-21 11:29 ` Greg KH
2021-08-23 0:54 ` Sasha Levin
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2021-08-21 11:29 UTC (permalink / raw)
To: Leah Rumancik; +Cc: stable, miklos, Murphy Zhou, Miklos Szeredi
On Fri, Aug 20, 2021 at 07:59:29PM +0000, Leah Rumancik wrote:
> From: Murphy Zhou <jencce.kernel@gmail.com>
>
> Now overlayfs falls back to use default file splice read
> and write, which is not compatiple with overlayfs, returning
> EFAULT. xfstests generic/591 can reproduce part of this.
>
> Tested this patch with xfstests auto group tests.
>
> [ Needed in 5.4 to fix a deadlock triggered via
> xfstests overlay/019 -- Leah Rumancik ]
>
> Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> ---
> fs/overlayfs/file.c | 47 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ovl: add splice file read write helper
2021-08-20 19:59 [PATCH] ovl: add splice file read write helper Leah Rumancik
2021-08-21 11:29 ` Greg KH
@ 2021-08-23 0:54 ` Sasha Levin
1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2021-08-23 0:54 UTC (permalink / raw)
To: Leah Rumancik; +Cc: stable, miklos, Murphy Zhou, Miklos Szeredi
On Fri, Aug 20, 2021 at 07:59:29PM +0000, Leah Rumancik wrote:
>From: Murphy Zhou <jencce.kernel@gmail.com>
>
>Now overlayfs falls back to use default file splice read
>and write, which is not compatiple with overlayfs, returning
>EFAULT. xfstests generic/591 can reproduce part of this.
>
>Tested this patch with xfstests auto group tests.
>
>[ Needed in 5.4 to fix a deadlock triggered via
> xfstests overlay/019 -- Leah Rumancik ]
I've queued this up for 5.4, thanks Leah.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-23 0:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-20 19:59 [PATCH] ovl: add splice file read write helper Leah Rumancik
2021-08-21 11:29 ` Greg KH
2021-08-23 0:54 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox