]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fuse: check if copy_file_range() returns larger than requested size
authorMiklos Szeredi <mszeredi@redhat.com>
Tue, 12 Aug 2025 12:07:54 +0000 (14:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Sep 2025 14:35:46 +0000 (16:35 +0200)
commit e5203209b3935041dac541bc5b37efb44220cc0b upstream.

Just like write(), copy_file_range() should check if the return value is
less or equal to the requested number of bytes.

Reported-by: Chunsheng Luo <luochunsheng@ustc.edu>
Closes: https://lore.kernel.org/all/20250807062425.694-1-luochunsheng@ustc.edu/
Fixes: 88bc7d5097a1 ("fuse: add support for copy_file_range()")
Cc: <stable@vger.kernel.org> # v4.20
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/fuse/file.c

index f597f7e68e5014d0a392c65a00962768f10d7d86..260dcaf3512309838f10f6cf83ba60d13b467b26 100644 (file)
@@ -3295,6 +3295,9 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in,
                fc->no_copy_file_range = 1;
                err = -EOPNOTSUPP;
        }
+       if (!err && outarg.size > len)
+               err = -EIO;
+
        if (err)
                goto out;