From nobody Tue Dec 16 22:14:31 2025 Received: from mail-pf1-f228.google.com (mail-pf1-f228.google.com [209.85.210.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 908582EA178 for ; Mon, 15 Dec 2025 20:10:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765829430; cv=none; b=svay+G6R6jppX2OHzbXrl+oyGvIZ1YSYHiPqqt2HHTABicum74LTdcJGC/ls8jokjtRUv6asKibbL6K5BtAhrIYd/DMDTVlvzyJPBrzFOSmObsgP3YNEbaaUyN0hpJzTB8/cDBmYn7abZ6kMmXNg4QNefeyJabcCABIqxL3eya8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765829430; c=relaxed/simple; bh=o5lGEBDV5UAe201SZiJ5LVTaZ61EzzdPrWLpVnIezHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L8/t/i9r3Ief0hoGcy1yXVNIQJJpovmw+DrnF4571arquuKioKOLGwQS9lBG4ZsinhhUENxYDpQL+of5uTUH4Ew6mkCT4zXseN0d6fr7I/qh5/B/foRv8anQKgpy7HgwP6vrIcTXtGTu6/BgwZNqOCRGzyQyK8vYlygzli44c0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=T0HdSJ0H; arc=none smtp.client-ip=209.85.210.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="T0HdSJ0H" Received: by mail-pf1-f228.google.com with SMTP id d2e1a72fcca58-7ab689d3fa0so245231b3a.0 for ; Mon, 15 Dec 2025 12:10:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1765829428; x=1766434228; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0e/XFewNZHIQT+u9pv570Jztv9BwIrFZDFKmU9UVav0=; b=T0HdSJ0HoELXf1gIFv/QkxtaPA3vejxY+X+pLLDKoBnwDAOkGYhM4g2Zgn6+kbqI23 kdNf/DF5vQpLM7BEtN7T6SNBphnmzwwKevwYOVns3QDoS/KUQWckeTO+C8oaVCp7Tiub c4UjgPX1ajLVB7c6FTS/nJvBb9NiBwR72zMMoUzanOfzOrBebLVB0q2CfF4F3sOj7Awl 0NUK87g5COpmBboKnSd838vfWJwuOTjjdGgz/75IAhI/fBPVmTvtAVfXVcAoVvEIP6qE n8dVdOS8OoPnQBs9x+cT7LPvu0na0LbC+pahqvkz/mW7K95FM+7/ufndLyc85Fh4TOMi G6hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765829428; x=1766434228; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0e/XFewNZHIQT+u9pv570Jztv9BwIrFZDFKmU9UVav0=; b=mLNTICxQVFWiKupwC7xGOrs972T6jFdaU2oaSzH/+DlZ3fuiwwGh1ueOwGULGEyORk hfTveQeO9DcAyU7bEuVxj+PVHovD+UwrXb3osfzxDD/HsGFyI0Vf9SyC0mE3IqRVFswd rAN1SxshQbQWcIFG7gwsyvaFaylk1DQQtUzZvgLQI2A4A8pJlIBc3xluDyb5bdQHaLfj ZMdsAXZU7YdJaD9t7TR/A7qpy6n6snbdSDNbtZVgM9ypdsd/0w1DoZTIwFHc5I/RGHTO wNd9ieMse6Nc/yV0kPWLJ6KUoBdAKfiDQNI2LMLQMh2E3vuCVmZShPfOxL5wgD694g8u 5xJg== X-Forwarded-Encrypted: i=1; AJvYcCUeqQK/tMjfrdTvJ0YymEfXwJhJBhfjIvs0uor5vFKn+r2scCt9JKbMI91jLw3NN/i3Qy4KEwQj5CnLjdI=@vger.kernel.org X-Gm-Message-State: AOJu0YzjAQNfYz8H9SxXvPqzkp9VFFy9U2ITgJP+OFWX5aw0ZSAuVnnV 5KuTi+OpJCsvDV9aAyOCcgulybA+WhY0LhWDfmlwHspYM3AAVbBaz+61mVioxuM0kDRqHJnVIou vFKkZWOABlZh9NWl3BvWuYWgxPjyXEe8ZfkACTsu0E+pu1n362NF7 X-Gm-Gg: AY/fxX7bAw4vf7uyojkQxevl4iD1CuXMzamjmdH+HZbAw0GDsTFbk8xVboUVSw3I7NB 7L2ENi+pEJeSXaUd1N/zR18Q9hOmsGgF8ZWDN0yEVggBf1lVkT2X1WbjKIThvtQ4bFBDygL1Zw1 DEaNeAVXxifF6rmn7uxc/spWF7QSAaNDqw3CMjwYsRsXOeogAxcOztOi+416/gczen+oaqrXSoS lNI+j/zDbeXXCcWs2tkN32hEAA/u+X0iXT5nWGFdFIo+77Hd5cKz/rsVxzRrnyooCYbGS9r4Uz4 7B8c/AfSBjdCcKD8p1rVphabsOIBm18mnnsLVWHiLUn1t4IJx4ULsL10sxBzPu4mVqb4Q9LjGuv rP91umfCBZUqmNaUavIFzApbTNsA= X-Google-Smtp-Source: AGHT+IFXM8p3TwJdJCvpPaO3rA9ZkB9JG6xOKudOAnxLn3WwIdq94virxVk4I+/m85vem/IuaYkd6Xnpobb3 X-Received: by 2002:a05:6a00:2e15:b0:7b2:b20:e8d9 with SMTP id d2e1a72fcca58-7f6693a5b3cmr7963554b3a.6.1765829427516; Mon, 15 Dec 2025 12:10:27 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([2620:125:9017:12:36:3:5:0]) by smtp-relay.gmail.com with ESMTPS id d2e1a72fcca58-7f4c3ff229csm1929188b3a.6.2025.12.15.12.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Dec 2025 12:10:27 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (unknown [IPv6:2620:125:9007:640:ffff::1199]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id EB30F340BC4; Mon, 15 Dec 2025 13:10:26 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id E89D7E41D23; Mon, 15 Dec 2025 13:10:26 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Joanne Koong , Caleb Sander Mateos , kernel test robot Subject: [PATCH v5 3/6] io_uring: ensure io_uring_create() initializes submitter_task Date: Mon, 15 Dec 2025 13:09:06 -0700 Message-ID: <20251215200909.3505001-4-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251215200909.3505001-1-csander@purestorage.com> References: <20251215200909.3505001-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Closes: https://lore.kernel.org/oe-lkp/202512101405.a7a2bdb2-lkp@intel.com Signed-off-by: Caleb Sander Mateos --- 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_con= fig *config) * memory (locked/pinned vm). It's not used for anything else. */ mmgrab(current->mm); ctx->mm_account =3D current->mm; =20 + 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 =3D get_task_struct(current); + } + ret =3D io_allocate_scq_urings(ctx, config); if (ret) goto err; =20 ret =3D io_sq_offload_create(ctx, p); @@ -3662,19 +3671,10 @@ static __cold int io_uring_create(struct io_ctx_con= fig *config) if (copy_to_user(config->uptr, p, sizeof(*p))) { ret =3D -EFAULT; goto err; } =20 - 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 =3D get_task_struct(current); - } - file =3D io_uring_get_file(ctx); if (IS_ERR(file)) { ret =3D PTR_ERR(file); goto err; } --=20 2.45.2