lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 4 May 2020 23:14:24 +0300
From:   Pavel Begunkov <asml.silence@...il.com>
To:     Jens Axboe <axboe@...nel.dk>, Jann Horn <jannh@...gle.com>,
        io-uring@...r.kernel.org, linux-kernel@...r.kernel.org,
        Alexander Viro <viro@...iv.linux.org.uk>,
        linux-fsdevel <linux-fsdevel@...r.kernel.org>
Subject: Re: [PATCH for-5.7] io_uring: fix zero len do_splice()

On 04/05/2020 23:00, Pavel Begunkov wrote:
> do_splice() doesn't expect len to be 0. Just always return 0 in this
> case as splice(2) do.

There is a thing, splice/tee will always return success on len=0 even with
invalid fds. Fast return for len=0, should really has been done after basic
validation, but I don't want to break userspace.

Any ideas?

> 
> Fixes: 7d67af2c0134 ("io_uring: add splice(2) support")
> Reported-by: Jann Horn <jannh@...gle.com>
> Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
> ---
>  fs/io_uring.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 65458eda2127..d53a1ef2a205 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2772,16 +2772,19 @@ static int io_splice(struct io_kiocb *req, bool force_nonblock)
>  	struct file *out = sp->file_out;
>  	unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;
>  	loff_t *poff_in, *poff_out;
> -	long ret;
> +	long ret = 0;
>  
>  	if (force_nonblock)
>  		return -EAGAIN;
>  
>  	poff_in = (sp->off_in == -1) ? NULL : &sp->off_in;
>  	poff_out = (sp->off_out == -1) ? NULL : &sp->off_out;
> -	ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
> -	if (force_nonblock && ret == -EAGAIN)
> -		return -EAGAIN;
> +
> +	if (sp->len) {
> +		ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
> +		if (force_nonblock && ret == -EAGAIN)
> +			return -EAGAIN;
> +	}
>  
>  	io_put_file(req, in, (sp->flags & SPLICE_F_FD_IN_FIXED));
>  	req->flags &= ~REQ_F_NEED_CLEANUP;
> 

-- 
Pavel Begunkov

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ