[GIT PULL] i src/register: clean up ring state on failed resize mmap#1575
Open
bohmiiidd wants to merge 1 commit into
Open
[GIT PULL] i src/register: clean up ring state on failed resize mmap#1575bohmiiidd wants to merge 1 commit into
bohmiiidd wants to merge 1 commit into
Conversation
If io_uring_resize_rings() succeeds in the kernel but the subsequent mmap call fails, sq/cq may hold stale or error-encoded pointers such as ring_ptr = (void *)-ENOMEM. A later call to io_uring_queue_exit() would pass these to munmap, resulting in undefined behaviour. Zero out sq and cq before calling io_uring_queue_exit() so that the cleanup path is safe regardless of which mappings were established. Fixes: axboe#1574 Signed-off-by: Ahmed Abdelmoemen <ahmedabdelmoumen05@gmail.com>
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.
src/register: clean up ring state on failed resize mmap
When io_uring_resize_rings() succeeds on the kernel side but the
subsequent mmap() fails (e.g. due to RLIMIT_AS), the old rings have
already been unmapped and the kernel has committed to the new layout.
This leaves ring->sq and ring->cq holding stale or error-encoded
pointers (e.g. ring_ptr = (void *)-ENOMEM).
Any subsequent call like io_uring_get_sqe() or io_uring_submit()
will crash with SIGSEGV, and a call to io_uring_queue_exit() will
pass those dangling pointers to munmap(), resulting in undefined
behaviour.
Fix this by zeroing ring->sq and ring->cq before calling
io_uring_queue_exit() in the error path, so the ring is fully and
safely destroyed instead of left in a partially corrupted state.
Fixes: #1574
Signed-off-by: Ahmed Abdelmoemen ahmedabdelmoumen05@gmail.com
❯ git request-pull axboe-tree/master https://github.com/bohmiiidd/liburing fix/register-resize-mmap-cleanup
The following changes since commit ce320c7:
test/bind-listen: ensure 'ts' is set before io_uring_wait_cqe_timeout() (2026-05-11 13:50:15 -0600)
are available in the Git repository at:
https://github.com/bohmiiidd/liburing fix/register-resize-mmap-cleanup
for you to fetch changes up to 79da9db:
src/register: clean up ring state on failed resize mmap (2026-05-14 14:31:44 +0100)
Ahmed Abdelmoemen (1):
src/register: clean up ring state on failed resize mmap
src/register.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)