From: Bernd Schubert <bernd@bsbernd.com>
To: Chunsheng Luo <luochunsheng@ustc.edu>, miklos@szeredi.hu
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fuse: Move same-superblock check to fuse_copy_file_range
Date: Wed, 6 Aug 2025 22:55:11 +0200 [thread overview]
Message-ID: <7b8d5689-1024-4c36-80c9-1cbffcc43dc0@bsbernd.com> (raw)
In-Reply-To: <20250806135254.352-1-luochunsheng@ustc.edu>
On 8/6/25 15:52, Chunsheng Luo wrote:
> The copy_file_range COPY_FILE_SPLICE capability allows filesystems to
> handle cross-superblock copy. However, in the current fuse implementation,
> __fuse_copy_file_range accesses src_file->private_data under the assumption
> that it points to a fuse_file structure. When the source file belongs to a
> non-FUSE filesystem, it will leads to kernel panics.
>
> To resolve this, move the same-superblock check from __fuse_copy_file_range
> to fuse_copy_file_range to ensure both files belong to the same fuse
> superblock before accessing private_data.
>
> Signed-off-by: Chunsheng Luo <luochunsheng@ustc.edu>
> ---
> fs/fuse/file.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 95275a1e2f54..a29f1b84f11b 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -2984,9 +2984,6 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in,
> if (fc->no_copy_file_range)
> return -EOPNOTSUPP;
>
> - if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb)
> - return -EXDEV;
> -
> inode_lock(inode_in);
> err = fuse_writeback_range(inode_in, pos_in, pos_in + len - 1);
> inode_unlock(inode_in);
> @@ -3066,9 +3063,12 @@ static ssize_t fuse_copy_file_range(struct file *src_file, loff_t src_off,
> {
> ssize_t ret;
>
> + if (file_inode(src_file)->i_sb != file_inode(dst_file)->i_sb)
> + return splice_copy_file_range(src_file, src_off, dst_file,
> + dst_off, len);
> +
> ret = __fuse_copy_file_range(src_file, src_off, dst_file, dst_off,
> len, flags);
> -
> if (ret == -EOPNOTSUPP || ret == -EXDEV)
> ret = splice_copy_file_range(src_file, src_off, dst_file,
> dst_off, len);
I guess you can remove the check EXDEV here?
next prev parent reply other threads:[~2025-08-06 20:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 13:52 Chunsheng Luo
2025-08-06 20:55 ` Bernd Schubert [this message]
2025-08-07 8:40 ` Luis Henriques
2025-08-07 12:49 ` Chunsheng Luo
2025-08-08 9:55 ` Amir Goldstein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b8d5689-1024-4c36-80c9-1cbffcc43dc0@bsbernd.com \
--to=bernd@bsbernd.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luochunsheng@ustc.edu \
--cc=miklos@szeredi.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®