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 <aftern00n@qq.com> Signed-off-by: Suoxing Zhang <aftern00n@qq.com> Signed-off-by: Qingyue Zhang <chunzhennn@qq.com> Link: https://lore.kernel.org/r/tencent_4DBB3674C0419BEC2C0C525949DA410CA307@qq.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e4e6aae commit c64eff3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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)