Skip to content

Commit 47abea0

Browse files
committed
io_uring: fix off-by-one in sync cancelation file check
The passed in index should be validated against the number of registered files we have, it needs to be smaller than the index value to avoid going one beyond the end. Fixes: 78a861b ("io_uring: add sync cancelation API through io_uring_register()") Reported-by: Luo Likang <luolikang@nsfocus.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e1d0c6d commit 47abea0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

io_uring/cancel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static int __io_sync_cancel(struct io_uring_task *tctx,
218218
(cd->flags & IORING_ASYNC_CANCEL_FD_FIXED)) {
219219
unsigned long file_ptr;
220220

221-
if (unlikely(fd > ctx->nr_user_files))
221+
if (unlikely(fd >= ctx->nr_user_files))
222222
return -EBADF;
223223
fd = array_index_nospec(fd, ctx->nr_user_files);
224224
file_ptr = io_fixed_file_slot(&ctx->file_table, fd)->file_ptr;

0 commit comments

Comments
 (0)