Repository navigation
queue: reject a negative reg_index in io_uring_submit_and_wait_reg() - #1649
Open
ManoharPaturi wants to merge 1 commit into
Open
ManoharPaturi wants to merge 1 commit into
ManoharPaturi wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.