Skip to content

Commit c64eff3

Browse files
chunzhennnaxboe
authored andcommitted
io_uring/kbuf: fix signedness in this_len calculation
When importing and using buffers, buf->len is considered unsigned. However, buf->len is converted to signed int when committing. This can lead to unexpected behavior if the buffer is large enough to be interpreted as a negative value. Make min_t calculation unsigned. Fixes: ae98dbf ("io_uring/kbuf: add support for incremental buffer consumption") Co-developed-by: Suoxing Zhang <[email protected]> Signed-off-by: Suoxing Zhang <[email protected]> Signed-off-by: Qingyue Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent e4e6aae commit c64eff3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

io_uring/kbuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static bool io_kbuf_inc_commit(struct io_buffer_list *bl, int len)
3939
u32 this_len;
4040

4141
buf = io_ring_head_to_buf(bl->buf_ring, bl->head, bl->mask);
42-
this_len = min_t(int, len, buf->len);
42+
this_len = min_t(u32, len, buf->len);
4343
buf->len -= this_len;
4444
if (buf->len) {
4545
buf->addr += this_len;

0 commit comments

Comments
 (0)