Skip to content

[GIT PULL] i src/register: clean up ring state on failed resize mmap#1575

Open
bohmiiidd wants to merge 1 commit into
axboe:masterfrom
bohmiiidd:fix/register-resize-mmap-cleanup
Open

[GIT PULL] i src/register: clean up ring state on failed resize mmap#1575
bohmiiidd wants to merge 1 commit into
axboe:masterfrom
bohmiiidd:fix/register-resize-mmap-cleanup

Conversation

@bohmiiidd
Copy link
Copy Markdown

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(-)

@bohmiiidd bohmiiidd changed the title src/register: clean up ring state on failed resize mmap [GIT PULL] i src/register: clean up ring state on failed resize mmap May 14, 2026
@axboe
Copy link
Copy Markdown
Owner

axboe commented May 19, 2026

Would you mind just rebasing it? I don't have an issue with merge commits, but they should happen when it gets pulled, not as a backwards merge.

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>
@bohmiiidd bohmiiidd force-pushed the fix/register-resize-mmap-cleanup branch from 7e7ff2d to ee133f0 Compare May 19, 2026 13:31
@bohmiiidd
Copy link
Copy Markdown
Author

Updated, thanks

@bohmiiidd
Copy link
Copy Markdown
Author

Are you not considering merging the patch?

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.

io_uring_resize_rings: ring left in unusable state on mmap failure

2 participants