io_uring/net: keep recv buffer select length within MAX_RW_COUNT
PATCH 1/1 io_uring/net: keep recv buffer select length within MAX_RW_COUNT
Since commit dcbd1c054848 ("io_uring/net: let io_recv_buf_select return the length of the buffer region"), io_recv_buf_select() returns the selected length as an int. For a non-bundle recv with sqe->len == 0 the length comes from the ring provided buffer, which can be up to 4G, so a buffer of 2G or more makes io_recv() fail the request with a bogus negative result (e.g. -2147483648) instead of receiving into it. Clamp the length to MAX_RW_COUNT, which import_ubuf() limits the transfer to anyway.
--- io_uring/net.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/net.c +2 -0
@@ -1178,6 +1178,8 @@ static int io_recv_buf_select(struct io_kiocb *req, struct io_async_msghdr *kmsg *sel =io_buffer_select (req, &len, sr->buf_group, issue_flags);if (!sel->addr)return -ENOBUFS ; +/* ring provided buffers can be up to 4G, keep len an int */ + len =min_t (size_t, len,MAX_RW_COUNT ); sr->buf = sel->addr; sr->len = len; map_ubuf:
base-commit: fddcf4c5321b3ea5f72166c3fd36a9d1c34f80c7
Signature · 1 line
2.52.0.windows.1
Quoted 10 lines · Tamaki Yanagawa
Since commit
dcbd1c054848("io_uring/net: letio_recv_buf_selectreturn the length of the buffer region"),io_recv_buf_select()returns the selected length as an int. For a non-bundle recv withsqe->len== 0 the length comes from the ring provided buffer, which can be up to 4G, so a buffer of 2G or more makesio_recv()fail the request with a bogus negative result (e.g. -2147483648) instead of receiving into it. Clamp the length toMAX_RW_COUNT, whichimport_ubuf()limits the transfer to anyway.[...]
Applied, thanks!
[1/1] io_uring/net: keep recv buffer select length within MAX_RW_COUNT
commit: 96262cfab554cf11412de7a6247f0e82c94e130f
Best regards,
Signature · 1 line
Jens Axboe