Skip to content

Commit ab69838

Browse files
krismanaxboe
authored andcommitted
io_uring/kbuf: Fix check of BID wrapping in provided buffers
Commit 3851d25 ("io_uring: check for rollover of buffer ID when providing buffers") introduced a check to prevent wrapping the BID counter when sqe->off is provided, but it's off-by-one too restrictive, rejecting the last possible BID (65534). i.e., the following fails with -EINVAL. io_uring_prep_provide_buffers(sqe, addr, size, 0xFFFF, 0, 0); Fixes: 3851d25 ("io_uring: check for rollover of buffer ID when providing buffers") Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de> Link: https://lore.kernel.org/r/20231005000531.30800-2-krisman@suse.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 922a2c7 commit ab69838

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
@@ -352,7 +352,7 @@ int io_provide_buffers_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
352352
tmp = READ_ONCE(sqe->off);
353353
if (tmp > USHRT_MAX)
354354
return -E2BIG;
355-
if (tmp + p->nbufs >= USHRT_MAX)
355+
if (tmp + p->nbufs > USHRT_MAX)
356356
return -EINVAL;
357357
p->bid = tmp;
358358
return 0;

0 commit comments

Comments
 (0)