提交 b8c01559 编写于 作者: D Dylan Yudaken 提交者: Jens Axboe

io_uring: allow 0 length for buffer select

If user gives 0 for length, we can set it from the available buffer size.
Signed-off-by: NDylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220630091231.1456789-2-dylany@fb.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 6e73dffb
...@@ -115,7 +115,7 @@ static void __user *io_provided_buffer_select(struct io_kiocb *req, size_t *len, ...@@ -115,7 +115,7 @@ static void __user *io_provided_buffer_select(struct io_kiocb *req, size_t *len,
kbuf = list_first_entry(&bl->buf_list, struct io_buffer, list); kbuf = list_first_entry(&bl->buf_list, struct io_buffer, list);
list_del(&kbuf->list); list_del(&kbuf->list);
if (*len > kbuf->len) if (*len == 0 || *len > kbuf->len)
*len = kbuf->len; *len = kbuf->len;
req->flags |= REQ_F_BUFFER_SELECTED; req->flags |= REQ_F_BUFFER_SELECTED;
req->kbuf = kbuf; req->kbuf = kbuf;
...@@ -145,7 +145,7 @@ static void __user *io_ring_buffer_select(struct io_kiocb *req, size_t *len, ...@@ -145,7 +145,7 @@ static void __user *io_ring_buffer_select(struct io_kiocb *req, size_t *len,
buf = page_address(bl->buf_pages[index]); buf = page_address(bl->buf_pages[index]);
buf += off; buf += off;
} }
if (*len > buf->len) if (*len == 0 || *len > buf->len)
*len = buf->len; *len = buf->len;
req->flags |= REQ_F_BUFFER_RING; req->flags |= REQ_F_BUFFER_RING;
req->buf_list = bl; req->buf_list = bl;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册