diff options
author | Dylan Yudaken <dylany@fb.com> | 2022-06-30 02:12:20 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-07-24 18:39:16 -0600 |
commit | b8c015598c8ef9195b8a2a5089e275c4f64ca999 (patch) | |
tree | 3bfe11619a9637eab9265ee91462eb60fb84618c /io_uring/kbuf.c | |
parent | 6e73dffbb93cb8797cd4e42e98d837edf0f1a967 (diff) | |
download | lwn-b8c015598c8ef9195b8a2a5089e275c4f64ca999.tar.gz lwn-b8c015598c8ef9195b8a2a5089e275c4f64ca999.zip |
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: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220630091231.1456789-2-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/kbuf.c')
-rw-r--r-- | io_uring/kbuf.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index 5e00f16e89b8..e538fa7cb727 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -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); list_del(&kbuf->list); - if (*len > kbuf->len) + if (*len == 0 || *len > kbuf->len) *len = kbuf->len; req->flags |= REQ_F_BUFFER_SELECTED; req->kbuf = kbuf; @@ -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 += off; } - if (*len > buf->len) + if (*len == 0 || *len > buf->len) *len = buf->len; req->flags |= REQ_F_BUFFER_RING; req->buf_list = bl; |