[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxitFgaO4D5pg54b0xj3Hnt61a+3BAHnEd_t3T9yzpXptg@mail.gmail.com>
Date: Fri, 5 Jul 2024 15:27:12 +0300
From: Amir Goldstein <amir73il@...il.com>
To: ed.tsai@...iatek.com
Cc: Miklos Szeredi <miklos@...redi.hu>, Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>, wsd_upstream@...iatek.com,
chun-hung.wu@...iatek.com, casper.li@...iatek.com,
linux-fsdevel@...r.kernel.org, linux-unionfs@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH 1/1] backing-file: covert to using fops->splice_write
On Fri, Jul 5, 2024 at 11:17 AM <ed.tsai@...iatek.com> wrote:
>
> From: Ed Tsai <ed.tsai@...iatek.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@...iatek.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
>
Powered by blists - more mailing lists