[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251215200909.3505001-4-csander@purestorage.com>
Date: Mon, 15 Dec 2025 13:09:06 -0700
From: Caleb Sander Mateos <csander@...estorage.com>
To: Jens Axboe <axboe@...nel.dk>,
io-uring@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Joanne Koong <joannelkoong@...il.com>,
Caleb Sander Mateos <csander@...estorage.com>,
kernel test robot <oliver.sang@...el.com>
Subject: [PATCH v5 3/6] io_uring: ensure io_uring_create() initializes submitter_task
If io_uring_create() fails after allocating the struct io_ring_ctx, it
may call io_ring_ctx_wait_and_kill() before submitter_task has been
assigned. This is currently harmless, as the submit and register paths
that check submitter_task aren't reachable until the io_ring_ctx has
been successfully created. However, a subsequent commit will expect
submitter_task to be set for every IORING_SETUP_SINGLE_ISSUER &&
!IORING_SETUP_R_DISABLED ctx. So assign ctx->submitter_task prior to any
call to io_ring_ctx_wait_and_kill() in io_uring_create().
Reported-by: kernel test robot <oliver.sang@...el.com>
Closes: https://lore.kernel.org/oe-lkp/202512101405.a7a2bdb2-lkp@intel.com
Signed-off-by: Caleb Sander Mateos <csander@...estorage.com>
---
io_uring/io_uring.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 44ff5756b328..6d6fe5bdebda 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3647,10 +3647,19 @@ static __cold int io_uring_create(struct io_ctx_config *config)
* memory (locked/pinned vm). It's not used for anything else.
*/
mmgrab(current->mm);
ctx->mm_account = current->mm;
+ if (ctx->flags & IORING_SETUP_SINGLE_ISSUER
+ && !(ctx->flags & IORING_SETUP_R_DISABLED)) {
+ /*
+ * Unlike io_register_enable_rings(), don't need WRITE_ONCE()
+ * since ctx isn't yet accessible from other tasks
+ */
+ ctx->submitter_task = get_task_struct(current);
+ }
+
ret = io_allocate_scq_urings(ctx, config);
if (ret)
goto err;
ret = io_sq_offload_create(ctx, p);
@@ -3662,19 +3671,10 @@ static __cold int io_uring_create(struct io_ctx_config *config)
if (copy_to_user(config->uptr, p, sizeof(*p))) {
ret = -EFAULT;
goto err;
}
- if (ctx->flags & IORING_SETUP_SINGLE_ISSUER
- && !(ctx->flags & IORING_SETUP_R_DISABLED)) {
- /*
- * Unlike io_register_enable_rings(), don't need WRITE_ONCE()
- * since ctx isn't yet accessible from other tasks
- */
- ctx->submitter_task = get_task_struct(current);
- }
-
file = io_uring_get_file(ctx);
if (IS_ERR(file)) {
ret = PTR_ERR(file);
goto err;
}
--
2.45.2
Powered by blists - more mailing lists