diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2020-05-04 23:00:54 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-05-09 10:16:10 -0600 |
commit | c96874265cd04b4bd4a8e114ac9af039a6d83cfe (patch) | |
tree | cae6a3895c52a37ab4215f262e76c319d78a8dbd /fs | |
parent | 63ff822358b276137059520cf16e587e8073e80f (diff) | |
download | linux-c96874265cd04b4bd4a8e114ac9af039a6d83cfe.tar.gz linux-c96874265cd04b4bd4a8e114ac9af039a6d83cfe.tar.bz2 linux-c96874265cd04b4bd4a8e114ac9af039a6d83cfe.zip |
io_uring: fix zero len do_splice()
do_splice() doesn't expect len to be 0. Just always return 0 in this
case as splice(2) does.
Fixes: 7d67af2c0134 ("io_uring: add splice(2) support")
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/io_uring.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 979d9f977409..4c2fe06ae20b 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2767,16 +2767,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; |