Skip to content

queue: reject a negative reg_index in io_uring_submit_and_wait_reg() - #1649

Open
ManoharPaturi wants to merge 1 commit into
axboe:masterfrom
ManoharPaturi:wait-reg-negative-index
Open

ManoharPaturi wants to merge 1 commit into
axboe:masterfrom
ManoharPaturi:wait-reg-negative-index

Conversation

@ManoharPaturi

Copy link
Copy Markdown

reg_index is multiplied by sizeof(struct io_uring_reg_wait) to compute the byte offset into the registered wait region, and the offset is then handed to the kernel as the wait argument. The index is a signed int, so a negative value widens to a very large unsigned long offset. The kernel rejects offsets outside the registered region, but the library can catch clearly invalid input first and return -EINVAL without touching any submission state, in the same way io_uring_opcode_supported() rejects a negative opcode.

Testing: test/reg-wait.c gains a case that queues an SQE, calls io_uring_submit_and_wait_reg() with an index of -1, and checks that it returns -EINVAL while the pending SQE is left unflushed.

reg_index is multiplied by sizeof(struct io_uring_reg_wait) to form the
byte offset into the registered wait region. A negative index sign
extends to a huge unsigned long offset, which is then handed to the
kernel as the wait argument. The kernel rejects out of range offsets,
but the library can bail out early with -EINVAL so clearly invalid
input does not depend on kernel range checking and no submission state
is touched.

Add a test checking that a negative index returns -EINVAL without
flushing pending SQEs.
Copilot AI balanced review requested due to automatic review settings October 4, 2026 02:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants