Subject: [PATCH 2511/2944] io_uring: fix 0-iov read buffer select

From: Pavel Begunkov <[email-masked]>
Date: Sat, 19 Dec 2020 03:15:43 +0000

fix #32116536

commit dd20166236953c8cd14f4c668bf972af32f0c6be upstream.

Doing vectored buf-select read with 0 iovec passed is meaningless and
utterly broken, forbid it.

Cc: <[email-masked]> # 5.7+
Signed-off-by: Pavel Begunkov <[email-masked]>
Signed-off-by: Jens Axboe <[email-masked]>
Signed-off-by: Jeffle Xu <[email-masked]>
Reviewed-by: Joseph Qi <[email-masked]>
---
 fs/io_uring.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 3648faf..093e5e6 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2668,9 +2668,7 @@ static ssize_t io_iov_buffer_select(struct io_kiocb *req, struct iovec *iov,
 		iov[0].iov_len = kbuf->len;
 		return 0;
 	}
-	if (!req->rw.len)
-		return 0;
-	else if (req->rw.len > 1)
+	if (req->rw.len != 1)
 		return -EINVAL;
 
 #ifdef CONFIG_COMPAT
-- 
1.8.3.1