Skip to content

Commit 3b5c757

Browse files
committed
io_uring/kbuf: fix signedness in this_len calculation
JIRA: https://issues.redhat.com/browse/RHEL-116130 commit c64eff3 Author: Qingyue Zhang <chunzhennn@qq.com> Date: Wed Aug 27 19:43:39 2025 +0800 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> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
1 parent 3e7b609 commit 3b5c757

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)