Skip to content

queue: fix NULL deref in _io_uring_get_cqe() for EXT_ARG_REG path#1581

Merged
axboe merged 1 commit into
axboe:masterfrom
XananasX7:fix/submit-and-wait-reg-sigsegv
May 26, 2026
Merged

queue: fix NULL deref in _io_uring_get_cqe() for EXT_ARG_REG path#1581
axboe merged 1 commit into
axboe:masterfrom
XananasX7:fix/submit-and-wait-reg-sigsegv

Conversation

@XananasX7

@XananasX7 XananasX7 commented May 26, 2026

Copy link
Copy Markdown
Contributor

When io_uring_submit_and_wait_reg() is used, data->arg holds a register
offset cast to void *, not a pointer to io_uring_getevents_arg. If no CQE
is available on the first pass, the looped && has_ts branch dereferences
data->arg as a struct pointer, which causes a segfault.

Fix this by checking IORING_ENTER_EXT_ARG_REG in get_flags before the
dereference. For the registered-wait path the kernel handles the timeout,
so return -ETIME directly without touching data->arg.

Fixes #1567.

@axboe

axboe commented May 26, 2026

Copy link
Copy Markdown
Owner

Looks reasonable, but please follow the commit guide for liburing. Basically everything you put in here needs to go in the commit message, but please keep it less LLM and more normal reading (and shorter). And you need a Signed-off-by line with a real identity + email.

@XananasX7 XananasX7 force-pushed the fix/submit-and-wait-reg-sigsegv branch from 0dce0a9 to 742bbae Compare May 26, 2026 22:05
@XananasX7 XananasX7 changed the title Fix SIGSEGV in io_uring_submit_and_wait_reg: offset misinterpreted as pointer in timeout path queue: fix NULL deref in _io_uring_get_cqe() for EXT_ARG_REG path May 26, 2026
@XananasX7

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. I've rewritten the commit message to be shorter and plain — no more verbose structure, and the key info is in the body now. Also added the Signed-off-by line. PR description updated to match.

When io_uring_submit_and_wait_reg() is used, data->arg holds a register
offset cast to void *, not a pointer to io_uring_getevents_arg. If no CQE
is available on the first pass, the looped && has_ts branch dereferences
data->arg as a struct pointer, which causes a segfault.

Fix this by checking IORING_ENTER_EXT_ARG_REG in get_flags before the
dereference. For the registered-wait path the kernel handles the timeout,
so return -ETIME directly without touching data->arg.

Fixes axboe#1567.
Signed-off-by: XananasX <cihbank069@gmail.com>
@XananasX7 XananasX7 force-pushed the fix/submit-and-wait-reg-sigsegv branch from 742bbae to 19903c3 Compare May 26, 2026 22:06
@axboe

axboe commented May 26, 2026

Copy link
Copy Markdown
Owner

Thanks, that looks much better. I'll run this through some testing.

@axboe axboe merged commit 63bf649 into axboe:master May 26, 2026
20 checks passed
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.

Memory access violation when using io_uring_submit_and_wait_reg()

2 participants