* [PATCH 1/1] backing-file: covert to using fops->splice_write
@ 2024-07-05 8:16 ed.tsai
2024-07-05 8:20 ` Ed Tsai (蔡宗軒)
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: ed.tsai @ 2024-07-05 8:16 UTC (permalink / raw)
To: Miklos Szeredi, Amir Goldstein, Alexander Viro, Christian Brauner,
Jan Kara, Matthias Brugger, AngeloGioacchino Del Regno
Cc: wsd_upstream, chun-hung.wu, casper.li, Ed Tsai, linux-fsdevel,
linux-unionfs, linux-kernel, linux-arm-kernel, linux-mediatek
From: Ed Tsai <ed.tsai@mediatek.com>
Filesystems may define their own splice write. Therefore, use file
fops instead of invoking iter_file_splice_write() directly.
Signed-off-by: Ed Tsai <ed.tsai@mediatek.com>
---
fs/backing-file.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/backing-file.c b/fs/backing-file.c
index 740185198db3..687a7fae7d25 100644
--- a/fs/backing-file.c
+++ b/fs/backing-file.c
@@ -280,13 +280,16 @@ ssize_t backing_file_splice_write(struct pipe_inode_info *pipe,
if (WARN_ON_ONCE(!(out->f_mode & FMODE_BACKING)))
return -EIO;
+ if (out->f_op->splice_write)
+ return -EINVAL;
+
ret = file_remove_privs(ctx->user_file);
if (ret)
return ret;
old_cred = override_creds(ctx->cred);
file_start_write(out);
- ret = iter_file_splice_write(pipe, out, ppos, len, flags);
+ ret = out->f_op->splice_write(pipe, out, ppos, len, flags);
file_end_write(out);
revert_creds(old_cred);
--
2.18.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] backing-file: covert to using fops->splice_write
2024-07-05 8:16 [PATCH 1/1] backing-file: covert to using fops->splice_write ed.tsai
@ 2024-07-05 8:20 ` Ed Tsai (蔡宗軒)
2024-07-05 12:27 ` Amir Goldstein
2024-07-07 20:42 ` Matthew Wilcox
2 siblings, 0 replies; 5+ messages in thread
From: Ed Tsai (蔡宗軒) @ 2024-07-05 8:20 UTC (permalink / raw)
To: viro@zeniv.linux.org.uk, miklos@szeredi.hu, amir73il@gmail.com,
matthias.bgg@gmail.com, jack@suse.cz, brauner@kernel.org,
angelogioacchino.delregno@collabora.com
Cc: linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
wsd_upstream, Casper Li (李中榮),
Chun-Hung Wu (巫駿宏),
linux-unionfs@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-fsdevel@vger.kernel.org
On Fri, 2024-07-05 at 16:16 +0800, ed.tsai@mediatek.com wrote:
> From: Ed Tsai <ed.tsai@mediatek.com>
>
> Filesystems may define their own splice write. Therefore, use file
> fops instead of invoking iter_file_splice_write() directly.
>
> Signed-off-by: Ed Tsai <ed.tsai@mediatek.com>
> ---
> fs/backing-file.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/backing-file.c b/fs/backing-file.c
> index 740185198db3..687a7fae7d25 100644
> --- a/fs/backing-file.c
> +++ b/fs/backing-file.c
> @@ -280,13 +280,16 @@ ssize_t backing_file_splice_write(struct
> pipe_inode_info *pipe,
> if (WARN_ON_ONCE(!(out->f_mode & FMODE_BACKING)))
> return -EIO;
>
> + if (out->f_op->splice_write)
> + return -EINVAL;
> +
> ret = file_remove_privs(ctx->user_file);
> if (ret)
> return ret;
>
> old_cred = override_creds(ctx->cred);
> file_start_write(out);
> - ret = iter_file_splice_write(pipe, out, ppos, len, flags);
> + ret = out->f_op->splice_write(pipe, out, ppos, len, flags);
> file_end_write(out);
> revert_creds(old_cred);
>
s/covert/convert/ for subject
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] backing-file: covert to using fops->splice_write
2024-07-05 8:16 [PATCH 1/1] backing-file: covert to using fops->splice_write ed.tsai
2024-07-05 8:20 ` Ed Tsai (蔡宗軒)
@ 2024-07-05 12:27 ` Amir Goldstein
2024-07-07 20:42 ` Matthew Wilcox
2 siblings, 0 replies; 5+ messages in thread
From: Amir Goldstein @ 2024-07-05 12:27 UTC (permalink / raw)
To: ed.tsai
Cc: Miklos Szeredi, Alexander Viro, Christian Brauner, Jan Kara,
Matthias Brugger, AngeloGioacchino Del Regno, wsd_upstream,
chun-hung.wu, casper.li, linux-fsdevel, linux-unionfs,
linux-kernel, linux-arm-kernel, linux-mediatek
On Fri, Jul 5, 2024 at 11:17 AM <ed.tsai@mediatek.com> wrote:
>
> From: Ed Tsai <ed.tsai@mediatek.com>
>
> Filesystems may define their own splice write. Therefore, use file
> fops instead of invoking iter_file_splice_write() directly.
This looks sane, but can you share the scenario where you ran into this?
or did you find this via code audit?
I can think of these cases:
1. overlayfs with fuse (virtiofs) upper
2. fuse passthrough over fuse
3. fuse passthrough over overlayfs
4. fuse passthrough over gfs2 or some out of tree fs
The first two will not cause any harm,
In case #3, according to the comment above ovl_splice_write()
the current code could even deadlock.
So do you have a reproduction?
Thanks,
Amir.
>
> Signed-off-by: Ed Tsai <ed.tsai@mediatek.com>
> ---
> fs/backing-file.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/backing-file.c b/fs/backing-file.c
> index 740185198db3..687a7fae7d25 100644
> --- a/fs/backing-file.c
> +++ b/fs/backing-file.c
> @@ -280,13 +280,16 @@ ssize_t backing_file_splice_write(struct pipe_inode_info *pipe,
> if (WARN_ON_ONCE(!(out->f_mode & FMODE_BACKING)))
> return -EIO;
>
> + if (out->f_op->splice_write)
> + return -EINVAL;
> +
> ret = file_remove_privs(ctx->user_file);
> if (ret)
> return ret;
>
> old_cred = override_creds(ctx->cred);
> file_start_write(out);
> - ret = iter_file_splice_write(pipe, out, ppos, len, flags);
> + ret = out->f_op->splice_write(pipe, out, ppos, len, flags);
> file_end_write(out);
> revert_creds(old_cred);
>
> --
> 2.18.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] backing-file: covert to using fops->splice_write
2024-07-05 8:16 [PATCH 1/1] backing-file: covert to using fops->splice_write ed.tsai
2024-07-05 8:20 ` Ed Tsai (蔡宗軒)
2024-07-05 12:27 ` Amir Goldstein
@ 2024-07-07 20:42 ` Matthew Wilcox
2024-07-07 23:52 ` Ed Tsai (蔡宗軒)
2 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2024-07-07 20:42 UTC (permalink / raw)
To: ed.tsai
Cc: Miklos Szeredi, Amir Goldstein, Alexander Viro, Christian Brauner,
Jan Kara, Matthias Brugger, AngeloGioacchino Del Regno,
wsd_upstream, chun-hung.wu, casper.li, linux-fsdevel,
linux-unionfs, linux-kernel, linux-arm-kernel, linux-mediatek
On Fri, Jul 05, 2024 at 04:16:39PM +0800, ed.tsai@mediatek.com wrote:
> +++ b/fs/backing-file.c
> @@ -280,13 +280,16 @@ ssize_t backing_file_splice_write(struct pipe_inode_info *pipe,
> if (WARN_ON_ONCE(!(out->f_mode & FMODE_BACKING)))
> return -EIO;
>
> + if (out->f_op->splice_write)
> + return -EINVAL;
Umm ... shouldn't this have been !out->f_op->splice_write?
> ret = file_remove_privs(ctx->user_file);
> if (ret)
> return ret;
>
> old_cred = override_creds(ctx->cred);
> file_start_write(out);
> - ret = iter_file_splice_write(pipe, out, ppos, len, flags);
> + ret = out->f_op->splice_write(pipe, out, ppos, len, flags);
> file_end_write(out);
> revert_creds(old_cred);
>
> --
> 2.18.0
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] backing-file: covert to using fops->splice_write
2024-07-07 20:42 ` Matthew Wilcox
@ 2024-07-07 23:52 ` Ed Tsai (蔡宗軒)
0 siblings, 0 replies; 5+ messages in thread
From: Ed Tsai (蔡宗軒) @ 2024-07-07 23:52 UTC (permalink / raw)
To: willy@infradead.org
Cc: linux-kernel@vger.kernel.org, amir73il@gmail.com,
linux-mediatek@lists.infradead.org, miklos@szeredi.hu,
viro@zeniv.linux.org.uk, Chun-Hung Wu (巫駿宏),
linux-unionfs@vger.kernel.org, brauner@kernel.org,
linux-fsdevel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com,
angelogioacchino.delregno@collabora.com, jack@suse.cz
On Fri, 2024-07-05 at 15:27 +0300, Amir Goldstein wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> On Fri, Jul 5, 2024 at 11:17 AM <ed.tsai@mediatek.com> wrote:
> >
> > From: Ed Tsai <ed.tsai@mediatek.com>
> >
> > Filesystems may define their own splice write. Therefore, use file
> > fops instead of invoking iter_file_splice_write() directly.
>
> This looks sane, but can you share the scenario where you ran into
> this?
> or did you find this via code audit?
>
> I can think of these cases:
> 1. overlayfs with fuse (virtiofs) upper
> 2. fuse passthrough over fuse
> 3. fuse passthrough over overlayfs
> 4. fuse passthrough over gfs2 or some out of tree fs
>
> The first two will not cause any harm,
> In case #3, according to the comment above ovl_splice_write()
> the current code could even deadlock.
>
> So do you have a reproduction?
>
> Thanks,
> Amir.
I came across this while checking what's new in the next LTS kernel.
This appears to be taken from overlayfs, and currently, no one has
encountered any issus about this.
On Sun, 2024-07-07 at 21:42 +0100, Matthew Wilcox wrote:
> On Fri, Jul 05, 2024 at 04:16:39PM +0800, ed.tsai@mediatek.com wrote:
> > +++ b/fs/backing-file.c
> > @@ -280,13 +280,16 @@ ssize_t backing_file_splice_write(struct
> pipe_inode_info *pipe,
> > if (WARN_ON_ONCE(!(out->f_mode & FMODE_BACKING)))
> > return -EIO;
> >
> > +if (out->f_op->splice_write)
> > +return -EINVAL;
>
> Umm ... shouldn't this have been !out->f_op->splice_write?
>
OMG... This is the wrong version. I will send the correct on later.
> > ret = file_remove_privs(ctx->user_file);
> > if (ret)
> > return ret;
> >
> > old_cred = override_creds(ctx->cred);
> > file_start_write(out);
> > -ret = iter_file_splice_write(pipe, out, ppos, len, flags);
> > +ret = out->f_op->splice_write(pipe, out, ppos, len, flags);
> > file_end_write(out);
> > revert_creds(old_cred);
> >
> > --
> > 2.18.0
> >
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-07 23:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-05 8:16 [PATCH 1/1] backing-file: covert to using fops->splice_write ed.tsai
2024-07-05 8:20 ` Ed Tsai (蔡宗軒)
2024-07-05 12:27 ` Amir Goldstein
2024-07-07 20:42 ` Matthew Wilcox
2024-07-07 23:52 ` Ed Tsai (蔡宗軒)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).