Skip to content

Commit d1f8280

Browse files
Thadeu Lima de Souza Cascardoaxboe
authored andcommitted
io_uring: truncate lengths larger than MAX_RW_COUNT on provide buffers
Read and write operations are capped to MAX_RW_COUNT. Some read ops rely on that limit, and that is not guaranteed by the IORING_OP_PROVIDE_BUFFERS. Truncate those lengths when doing io_add_buffers, so buffer addresses still use the uncapped length. Also, take the chance and change struct io_buffer len member to __u32, so it matches struct io_provide_buffer len member. This fixes CVE-2021-3491, also reported as ZDI-CAN-13546. Fixes: ddf0322 ("io_uring: add IORING_OP_PROVIDE_BUFFERS") Reported-by: Billy Jheng Bing-Jhong (@st424204) Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent bb6659c commit d1f8280

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/io_uring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ struct io_rsrc_data {
251251
struct io_buffer {
252252
struct list_head list;
253253
__u64 addr;
254-
__s32 len;
254+
__u32 len;
255255
__u16 bid;
256256
};
257257

@@ -3986,7 +3986,7 @@ static int io_add_buffers(struct io_provide_buf *pbuf, struct io_buffer **head)
39863986
break;
39873987

39883988
buf->addr = addr;
3989-
buf->len = pbuf->len;
3989+
buf->len = min_t(__u32, pbuf->len, MAX_RW_COUNT);
39903990
buf->bid = bid;
39913991
addr += pbuf->len;
39923992
bid++;

0 commit comments

Comments
 (0)