From nobody Sat Feb 7 05:01:29 2026 Received: from mail-ej1-f97.google.com (mail-ej1-f97.google.com [209.85.218.97]) (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 5BD6A2D640D for ; Mon, 5 Jan 2026 21:05:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767647154; cv=none; b=LYAPjPwlbWnLNdA5y/xilfOmHjzAW3ZwM6fxkuK2xiJyfGLHm1b021tgHxHq+/BMc5w7C/FdqJiJaJe/vY39fbEKJ1vXnykpGU+TtkK0qWZdPevAoeXAnxSkNIh6ZBlWwAFK+OuYXjcbkwFP77IwXKMJWDPY9/BnpW6UE0zppWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767647154; c=relaxed/simple; bh=nmBi4ylBnlgJaFlrj3RVOotCsUXiNn/BE5TBm+oiiek=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qJwB8xS5+Fypl/zCzjUMYdu+Dc6oHoJ8FH5iIVDmztjGtSU+TfzF7hgRmDwhjrCLTTU69MuPIb36Zzkg0j1xy/ImMQz0gOXqb+Cp8m7pUysiVrWS+/uLnJo/U71Z98AK4SYEZDBz6idtqDxc9NgHZGaYugaYulyM1BkRXfqtAGo= 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=Nq9kFQ5+; arc=none smtp.client-ip=209.85.218.97 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="Nq9kFQ5+" Received: by mail-ej1-f97.google.com with SMTP id a640c23a62f3a-b734a4b788cso5514166b.3 for ; Mon, 05 Jan 2026 13:05:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1767647150; x=1768251950; 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=cyfDolQw3Z8ZI7bCxJjqh+dHMcXjL+jvfGwEoLEbA+w=; b=Nq9kFQ5+AN+Kr2SSBDet0wSupF0Wf+mntZS+CIHNd9Oi99NhdE9l87rSfMriFIpCLN VYP7irPOPQqtHyMSPQGAKcJAL6kLUx3HZoRV8gX4MBhM7p5dacuIrlQu+Rlz1HuMEgXg SaunMrwTQbitElmfzv/bqO+QVUksTB3cT3i14ixVoE7Vl3XmMFb33y+kPWnSZfZHqt3k 1eejXHHuapOP1SHcuc+y+zG3pizG10ZDzrvdWS3mRQQtHaU57G+83g2Y06ip3/Ob+aik n7c2EQUTC3s1acvTIxX8/c5mZPk1xpnT7hIzauWEEJ/sWVlVACJiarp/shaNkMh9axHp egQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767647150; x=1768251950; 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=cyfDolQw3Z8ZI7bCxJjqh+dHMcXjL+jvfGwEoLEbA+w=; b=hGw4bRdAG9tRaE1Dgdeq75pg/8k05JHjn3dRVdO/WUFYIUnPZGhCLwbBKodtTG7L7Y Rcoy0mghc9bFu+ghyl6OJKUjctdNWtTxeTDI47pgINTQTPRqXUshFCVSOa+Dlv99VjLz n4jhKEqpAqTJ5L6gUD+Np9cLMWZ32Tpbtjf2C9Pq2wMDeUviU49Io5TW5BaOV0F9fVvS h6jffYlE/Byy5b8vNspcrmoca97K1C6GIs1TBtcUd+AONBTVEoSaWNSqSG1ZvO/+1qZT gkosF45nqPi+6/DjygAOvK1hUl9nK1dkwM8+WXY3kQOgeX90+cDP3KyNgFKfrNt3MNhw FV7Q== X-Forwarded-Encrypted: i=1; AJvYcCUHXIfIPUd4BSjpkWwbPWyiEcpLH28boUKqu1abaIDDanpQjpKjFhfxCkC1G75lq1JVO9FiK9jQ7AwMu0o=@vger.kernel.org X-Gm-Message-State: AOJu0YyBJ+4P/Y5Kzj4h1H8EYMha62vx1STUvvdnoG5ocE0pe4gOfPyK M6ruETNwVWI2NLf2Wb5Qv/MBCgvU3jAEfZjD9FCr2YplUDirKDZrZA3j5mdavo/wWguH70WiiiT vZcssPdhWnRFTUAx94eVAe4+wJ8kLrtUo7gm8 X-Gm-Gg: AY/fxX41oWx0/ci392X+tMlQvsYoYBWK6JQoYPaoTqTXmkhZnALfO2qiZQwxQW6D1UX Lzb59L1nm3u6mK1eOtqAF0r8FKf9sEOY+vcuHQo/GZCab1LGVKFPOttGgkI0Ab9SixuC0z91QXV i0hIB8b/1NKPRYwlRD+mkaxYkwqeSq84DPWlyqd1EJgEZreyTA5KFYdnrRpiDhhzL1f+N0GbS/i Nl4EN+HVFEmkwfRzgHWr+q3O/7lIMni6v5zIz74vWGVP7EG9WMiVuSiMHNSAEc2fw5iIkxscXGm OIlIZCwu9OzVM97bMwTgLS1T+TWeFi4CuSzonHfMb1OJ4H3p4fvcx9T5DuIbkDjkXm8Jjr43t4S o4Z3Uszw7NkLCSTMA/jy8j7eAk5dJbmXiQT0Qab308A== X-Google-Smtp-Source: AGHT+IGc1AymejhJS1np5fvi3CQGGvWfBlkLpPX2lfbta2+WC+h4KeaHA/L36auASuU9h9NFThmUSXgJoIFh X-Received: by 2002:a17:907:1b0f:b0:b7a:2ba7:18bf with SMTP id a640c23a62f3a-b842703f9aamr58945266b.5.1767647150443; Mon, 05 Jan 2026 13:05:50 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.129]) by smtp-relay.gmail.com with ESMTPS id a640c23a62f3a-b842a2102acsm1270766b.1.2026.01.05.13.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 13:05:50 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.49.34.222]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 2B16634173B; Mon, 5 Jan 2026 14:05:49 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 27FADE41BCB; Mon, 5 Jan 2026 14:05:49 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe Cc: Joanne Koong , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH v7 1/3] io_uring: use release-acquire ordering for IORING_SETUP_R_DISABLED Date: Mon, 5 Jan 2026 14:05:40 -0700 Message-ID: <20260105210543.3471082-2-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260105210543.3471082-1-csander@purestorage.com> References: <20260105210543.3471082-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" io_uring_enter(), __io_msg_ring_data(), and io_msg_send_fd() read ctx->flags and ctx->submitter_task without holding the ctx's uring_lock. This means they may race with the assignment to ctx->submitter_task and the clearing of IORING_SETUP_R_DISABLED from ctx->flags in io_register_enable_rings(). Ensure the correct ordering of the ctx->flags and ctx->submitter_task memory accesses by storing to ctx->flags using release ordering and loading it using acquire ordering. Signed-off-by: Caleb Sander Mateos Fixes: 4add705e4eeb ("io_uring: remove io_register_submitter") Reviewed-by: Joanne Koong Reviewed-by: Gabriel Krisman Bertazi --- io_uring/io_uring.c | 6 +++++- io_uring/msg_ring.c | 12 ++++++++++-- io_uring/register.c | 3 ++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 87a87396e940..ec27fafcb213 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3254,11 +3254,15 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u= 32, to_submit, goto out; } =20 ctx =3D file->private_data; ret =3D -EBADFD; - if (unlikely(ctx->flags & IORING_SETUP_R_DISABLED)) + /* + * Keep IORING_SETUP_R_DISABLED check before submitter_task load + * in io_uring_add_tctx_node() -> __io_uring_add_tctx_node_from_submit() + */ + if (unlikely(smp_load_acquire(&ctx->flags) & IORING_SETUP_R_DISABLED)) goto out; =20 /* * For SQ polling, the thread will do all submissions and completions. * Just return the requested submit count, and wake the thread if diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c index 7063ea7964e7..87b4d306cf1b 100644 --- a/io_uring/msg_ring.c +++ b/io_uring/msg_ring.c @@ -123,11 +123,15 @@ static int __io_msg_ring_data(struct io_ring_ctx *tar= get_ctx, =20 if (msg->src_fd || msg->flags & ~IORING_MSG_RING_FLAGS_PASS) return -EINVAL; if (!(msg->flags & IORING_MSG_RING_FLAGS_PASS) && msg->dst_fd) return -EINVAL; - if (target_ctx->flags & IORING_SETUP_R_DISABLED) + /* + * Keep IORING_SETUP_R_DISABLED check before submitter_task load + * in io_msg_data_remote() -> io_msg_remote_post() + */ + if (smp_load_acquire(&target_ctx->flags) & IORING_SETUP_R_DISABLED) return -EBADFD; =20 if (io_msg_need_remote(target_ctx)) return io_msg_data_remote(target_ctx, msg); =20 @@ -243,11 +247,15 @@ static int io_msg_send_fd(struct io_kiocb *req, unsig= ned int issue_flags) =20 if (msg->len) return -EINVAL; if (target_ctx =3D=3D ctx) return -EINVAL; - if (target_ctx->flags & IORING_SETUP_R_DISABLED) + /* + * Keep IORING_SETUP_R_DISABLED check before submitter_task load + * in io_msg_fd_remote() + */ + if (smp_load_acquire(&target_ctx->flags) & IORING_SETUP_R_DISABLED) return -EBADFD; if (!msg->src_file) { int ret =3D io_msg_grab_file(req, issue_flags); if (unlikely(ret)) return ret; diff --git a/io_uring/register.c b/io_uring/register.c index 3d3822ff3fd9..12318c276068 100644 --- a/io_uring/register.c +++ b/io_uring/register.c @@ -191,11 +191,12 @@ static int io_register_enable_rings(struct io_ring_ct= x *ctx) } =20 if (ctx->restrictions.registered) ctx->restricted =3D 1; =20 - ctx->flags &=3D ~IORING_SETUP_R_DISABLED; + /* Keep submitter_task store before clearing IORING_SETUP_R_DISABLED */ + smp_store_release(&ctx->flags, ctx->flags & ~IORING_SETUP_R_DISABLED); if (ctx->sq_data && wq_has_sleeper(&ctx->sq_data->wait)) wake_up(&ctx->sq_data->wait); return 0; } =20 --=20 2.45.2 From nobody Sat Feb 7 05:01:29 2026 Received: from mail-lj1-f227.google.com (mail-lj1-f227.google.com [209.85.208.227]) (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 59E022DCBFD for ; Mon, 5 Jan 2026 21:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767647155; cv=none; b=V8ToimbYSukaDryGXK4eqEeTDbSXUm0JhPuIe80yRPbk3gBYQUjkbFncWkWmZAVMRDCrFt1CSAF78yrc9IRQ7ziuBmZEsUCzfIAAX9IiqXWt1dfyRpviuvAYbnOEWbRLlEc6nWyB4VFy1WT2jqryJgqEGetZtg0hByR2rmqsmK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767647155; c=relaxed/simple; bh=viSjjzfK+LuCMgJk4GB2ln1Ib+FEY2Yal2i0Mc2zreo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sPwMtoaAeaeKtpIZwisRtnlLduRqo8v8HtSA5qvkAElqz1UKsZV8NjuxFheRHKKkm0vngf68fCS3ogmLwsm6uKvLlWozei8HnrNcjWtrmi71oP8tJaQyEGsczV5GqTtYhx2J3qaWV3W7XfbuIWoKYsJJO85GS8id9u3TINVTvx8= 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=HbuWoRsz; arc=none smtp.client-ip=209.85.208.227 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="HbuWoRsz" Received: by mail-lj1-f227.google.com with SMTP id 38308e7fff4ca-37a533a9f26so367201fa.2 for ; Mon, 05 Jan 2026 13:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1767647151; x=1768251951; 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=hwMUEMHMzWqjRsw9Dq1TO0aqVGzfagUbxeaLhQQuCYE=; b=HbuWoRszVnJvkyOC1DfO99GQ0fw4CPTt9p/VIFiF0usbnaIir61cxy7yI/tOI8O2JO ABXz/CDYr7UgOCWpJpxxJSF4jqaQs7De1zfjN/erafvoQcfZSq4VIA1wlPL61Yqdu1Am cHk1nUYwRvILTrd7SV5QYXiIs6SfL4rRmeaOol+WtWyCBw8r0Afq4q97o1tk2LPetqml magBshXSCrrSQE3M6OybOpS3EkRXYQo+m4MA1Yw7NZtWtrBnek+TlppDJq2eJuagPNMn FLCj3RKKnvcB1Wns9UmSypg4RXy1gDLS8dN3Xtzz6sGxzREInweKin1QL6kv4bls0AE3 le+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767647151; x=1768251951; 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=hwMUEMHMzWqjRsw9Dq1TO0aqVGzfagUbxeaLhQQuCYE=; b=I2mT3WT7Ikuzwy5+Gy5Zk915n8vFjxMZ4yIku7XRmMEkfMNYaebxJJtaD6uoYGik0v Z+qBOG+/YKsBTEGffVCzwZCGDzjTcB8VFR3AtuQ6V2ZIiIqcWviO68ipJtdylFCxhWtP o9+E4BaweqBp6/cKOTbFmlyjYoWF3TWj62nop3veGAHsHrdq+WA8eVXGuBd3h3lIkA5P dRJ0nX8tiq2vUqeX3jpz6lWtYwlOaneYsNAadtgD9sShxsr5HNZA1UOhH4UFIEQJG345 0XXT90mOpJYBMdLiupsjMXWDXmQwC8Q75g8UvycucuIiY5PW1cqOrNKk8j0B5nov6N+1 ntnQ== X-Forwarded-Encrypted: i=1; AJvYcCWLRUvjKdT/0kcZXDCf1koNs80zzeCqZZnYvE15wGsrieh+WHhq9AoqSvvqhNCumP0/7sN+FlhS+/n+YFM=@vger.kernel.org X-Gm-Message-State: AOJu0YweYMp9gv+czoC+wEopHa+9reR5PRqFCEtqVPSCPyIq2pIbB22C L/ki3ZW8IjMpQrdkIL5zP8PguQA0Bsl6fABUZsAvDRFcljUJdeSC/GK/Lrt2CtDf4AJPX8Ormin 54cUllCQj06m7PauC0PBCRnmj8v7bJGutPgBM X-Gm-Gg: AY/fxX41dSQf1d1j+97Brg21+7o7GPSKpot58h3xQCt8c02d+VKRTkxjvDMcv4alRDi buTpvdrWMxfSzxABfJ7wFXZFKMTQ51pHZ6iVf9TNZsVl6TwloDtt6LVRhQ4prk+ArLuY7LAJ+A2 OIvLqQ997V8oAzpaJiNyRpmrxyInCgCzEIUBM8e90+SG8tCaC1HCPiMeEoeJ5BU4X9KkCDCtN7Z beYjZ+VoufnYQeW8rmKW6dyXYpiiYUaB+y7CSjASAHHRX0OfZsVYkzO2QNaFM+qNG+/flgR+6l9 5STcn73C7IfRgouvDVjk/WXoVf2YRkAXcPSMC47IJnFiOUH9sfiKpCFWzfN/b0MYXWIVVlaPtMq K3zuKtRu4x3Ui49Q/c0L1zdph+iKJ+MlGGU1Pn9q0rg== X-Google-Smtp-Source: AGHT+IHq9xfUdD56ExprIKveYN6ABXutsP6x2ol6BJKZfSOWzDgQrOrFr+EvNDNHvpDTb78tIl0MqfgDkOUQ X-Received: by 2002:a05:6512:158b:b0:597:d7d6:eae1 with SMTP id 2adb3069b0e04-59b6527a359mr167691e87.2.1767647151230; Mon, 05 Jan 2026 13:05:51 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.128]) by smtp-relay.gmail.com with ESMTPS id 2adb3069b0e04-59b65d91980sm22466e87.41.2026.01.05.13.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 13:05:51 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.49.34.222]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 5ECA5341BBA; Mon, 5 Jan 2026 14:05:49 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 5B270E41BCB; Mon, 5 Jan 2026 14:05:49 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe Cc: Joanne Koong , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH v7 2/3] io_uring/msg_ring: drop unnecessary submitter_task checks Date: Mon, 5 Jan 2026 14:05:41 -0700 Message-ID: <20260105210543.3471082-3-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260105210543.3471082-1-csander@purestorage.com> References: <20260105210543.3471082-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" __io_msg_ring_data() checks that the target_ctx isn't IORING_SETUP_R_DISABLED before calling io_msg_data_remote(), which calls io_msg_remote_post(). So submitter_task can't be modified concurrently with the read in io_msg_remote_post(). Additionally, submitter_task must exist, as io_msg_data_remote() is only called for io_msg_need_remote(), i.e. task_complete is set, which requires IORING_SETUP_DEFER_TASKRUN, which in turn requires IORING_SETUP_SINGLE_ISSUER. And submitter_task is assigned in io_uring_create() or io_register_enable_rings() before enabling any IORING_SETUP_SINGLE_ISSUER io_ring_ctx. Similarly, io_msg_send_fd() checks IORING_SETUP_R_DISABLED and io_msg_need_remote() before calling io_msg_fd_remote(). submitter_task therefore can't be modified concurrently with the read in io_msg_fd_remote() and must be non-null. io_register_enable_rings() can't run concurrently because it's called from io_uring_register() -> __io_uring_register() with uring_lock held. Thus, replace the READ_ONCE() and WRITE_ONCE() of submitter_task with plain loads and stores. And remove the NULL checks of submitter_task in io_msg_remote_post() and io_msg_fd_remote(). Signed-off-by: Caleb Sander Mateos Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Joanne Koong --- io_uring/io_uring.c | 7 +------ io_uring/msg_ring.c | 18 +++++------------- io_uring/register.c | 2 +- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index ec27fafcb213..b31d88295297 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3663,17 +3663,12 @@ static __cold int io_uring_create(struct io_ctx_con= fig *config) 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->flags & IORING_SETUP_R_DISABLED)) ctx->submitter_task =3D get_task_struct(current); - } =20 file =3D io_uring_get_file(ctx); if (IS_ERR(file)) { ret =3D PTR_ERR(file); goto err; diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c index 87b4d306cf1b..57ad0085869a 100644 --- a/io_uring/msg_ring.c +++ b/io_uring/msg_ring.c @@ -78,26 +78,21 @@ static void io_msg_tw_complete(struct io_tw_req tw_req,= io_tw_token_t tw) io_add_aux_cqe(ctx, req->cqe.user_data, req->cqe.res, req->cqe.flags); kfree_rcu(req, rcu_head); percpu_ref_put(&ctx->refs); } =20 -static int io_msg_remote_post(struct io_ring_ctx *ctx, struct io_kiocb *re= q, +static void io_msg_remote_post(struct io_ring_ctx *ctx, struct io_kiocb *r= eq, int res, u32 cflags, u64 user_data) { - if (!READ_ONCE(ctx->submitter_task)) { - kfree_rcu(req, rcu_head); - return -EOWNERDEAD; - } req->opcode =3D IORING_OP_NOP; req->cqe.user_data =3D user_data; io_req_set_res(req, res, cflags); percpu_ref_get(&ctx->refs); req->ctx =3D ctx; req->tctx =3D NULL; req->io_task_work.func =3D io_msg_tw_complete; io_req_task_work_add_remote(req, IOU_F_TWQ_LAZY_WAKE); - return 0; } =20 static int io_msg_data_remote(struct io_ring_ctx *target_ctx, struct io_msg *msg) { @@ -109,12 +104,12 @@ static int io_msg_data_remote(struct io_ring_ctx *tar= get_ctx, return -ENOMEM; =20 if (msg->flags & IORING_MSG_RING_FLAGS_PASS) flags =3D msg->cqe_flags; =20 - return io_msg_remote_post(target_ctx, target, msg->len, flags, - msg->user_data); + io_msg_remote_post(target_ctx, target, msg->len, flags, msg->user_data); + return 0; } =20 static int __io_msg_ring_data(struct io_ring_ctx *target_ctx, struct io_msg *msg, unsigned int issue_flags) { @@ -125,11 +120,11 @@ static int __io_msg_ring_data(struct io_ring_ctx *tar= get_ctx, return -EINVAL; if (!(msg->flags & IORING_MSG_RING_FLAGS_PASS) && msg->dst_fd) return -EINVAL; /* * Keep IORING_SETUP_R_DISABLED check before submitter_task load - * in io_msg_data_remote() -> io_msg_remote_post() + * in io_msg_data_remote() -> io_req_task_work_add_remote() */ if (smp_load_acquire(&target_ctx->flags) & IORING_SETUP_R_DISABLED) return -EBADFD; =20 if (io_msg_need_remote(target_ctx)) @@ -225,14 +220,11 @@ static void io_msg_tw_fd_complete(struct callback_hea= d *head) =20 static int io_msg_fd_remote(struct io_kiocb *req) { struct io_ring_ctx *ctx =3D req->file->private_data; struct io_msg *msg =3D io_kiocb_to_cmd(req, struct io_msg); - struct task_struct *task =3D READ_ONCE(ctx->submitter_task); - - if (unlikely(!task)) - return -EOWNERDEAD; + struct task_struct *task =3D ctx->submitter_task; =20 init_task_work(&msg->tw, io_msg_tw_fd_complete); if (task_work_add(task, &msg->tw, TWA_SIGNAL)) return -EOWNERDEAD; =20 diff --git a/io_uring/register.c b/io_uring/register.c index 12318c276068..8104728af294 100644 --- a/io_uring/register.c +++ b/io_uring/register.c @@ -179,11 +179,11 @@ static int io_register_enable_rings(struct io_ring_ct= x *ctx) { if (!(ctx->flags & IORING_SETUP_R_DISABLED)) return -EBADFD; =20 if (ctx->flags & IORING_SETUP_SINGLE_ISSUER && !ctx->submitter_task) { - WRITE_ONCE(ctx->submitter_task, get_task_struct(current)); + ctx->submitter_task =3D get_task_struct(current); /* * Lazy activation attempts would fail if it was polled before * submitter_task is set. */ if (wq_has_sleeper(&ctx->poll_wq)) --=20 2.45.2 From nobody Sat Feb 7 05:01:29 2026 Received: from mail-lj1-f228.google.com (mail-lj1-f228.google.com [209.85.208.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 4E3EF2DC767 for ; Mon, 5 Jan 2026 21:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767647155; cv=none; b=Nuy8/Ci3Q0w8JrIycHysCGzKUkupt1/Q9skSUtiNTzDo0PCTfSKjylC3L1BcIXBWnFykXujMhRGx9u4B+S6JCsb5VjFqPuQxauwq+8YbI71SC9vFlk4Ee9lhqIub9LwGLN07+hQ5lufHsCN1/8FSVNbmmeMYHkcCvjAYObVELxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767647155; c=relaxed/simple; bh=B/TqW2AEv1uMhLD3CNnk8NlC/45nYR1F1/GepVbTJAM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z4n4VBDnyFospPic14HsDIF4BFkXQJELeCXW5KzUBgfclxV8KdiOL7PanWECvTzbimadMpGphcv7JX01cXGLm0IAyWwjmzPFtWJHhQIy2p+UswrAMJBE3lKsIZ6sZkElkLcgxMEPm4SwwcUROzc/HpqNJrj0aWfNwAS3VvTUNAQ= 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=TlQdqk7B; arc=none smtp.client-ip=209.85.208.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="TlQdqk7B" Received: by mail-lj1-f228.google.com with SMTP id 38308e7fff4ca-37a533a9f26so367211fa.2 for ; Mon, 05 Jan 2026 13:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1767647151; x=1768251951; 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=XWGiugkBdzXdQk4lm2s3M65iuqmFUc9XsicklsZBNyw=; b=TlQdqk7BKwmKtEMqj2ByYabIL8ucCyWXgBEJfd8ms2yqcyB/Ip2g46nqCANYrGqvbj TvBvH27Ot8znlp/CSlqoKkHW4P/Jx005S4nWLt7dl8NOnMOHXdBUhE5wjAfLDlkP+NVV FVl6MUD/xDMoVj3mtrGQL77asN2js2z/jE6a0Sxn0W6oNeIOUrkSzd/uQDJhenkKNI8y OJNqa/XTapvBnOGcv1H3xHmtNdFqt2/hiNj4e0CStMr6kHRoSpeK8o7bjXuWHcCYUIEF Od0xb/R6yw8W3CBwc+rjRDlsdD5nSIP2IlJPDp7R1FzRR6j+omm7oam3Qkqwj9rMzbvM WqFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767647151; x=1768251951; 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=XWGiugkBdzXdQk4lm2s3M65iuqmFUc9XsicklsZBNyw=; b=sX/G8OCo0Hgv4bae6Qqx1+CU+PPEGe6fBeR7mr9Rm1aEF9mqu/2MnIqJqVkFXBd9lA wzLBocu88JCbRZpVzjjcAihwTMQRN4+SLVS7TSrwWDo1oTWp40GVVu15sZIqKQm1eL4D wCzmybBhlUiNllL5n1swIwwUiOoFOZ3kfupQ/xE8Lf9LBwP/+aQxAM2ifTD1kE4oB4gh o4wJXDZZ669daHodUy10m8tbKqa0Cv1lfoo3fvzsD1HvQESFuTAQLzDb3Y/CVfboHhqw fxZ24XOLN49P4eWUpl5yEes0yOvAiTrelV7+0hfPYcRAruBnLETgOwRJwCoacqrETx7k jzHw== X-Forwarded-Encrypted: i=1; AJvYcCUWqkHLGK+Y0nPt687qU7vXYGHUHNP8S4X0zjnrLCj/dCpoRItkcOHnbeRK0F3ywemrZ9MVphTPvacMjVc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2XFDDvwYxz4i/vu6TQmhgPfoocF/WCHSzcd1ODSNiLEeFZBVe ZnScHrTyVBfYx1qimNFJR8rVAF3jpA/52ostDPa5uIaPmR+RnKuU99Lj59LPtxPpj8Q3xHLIgD0 Xhy4uf6r4nrsPp7kzhdxm2LTKm6qLchccvoSSNRCkpWVJq9jdl7iT X-Gm-Gg: AY/fxX6V+Kk6Vage+LuNQ1rsXYxRO87e0SmHk3/IxVOBo+mDebSYsU18/tZmSeQ0SOF Bo/GCQFq2zR0wkAw5cCAWFrDzxQvzUAMX1g/lnMouM9/PZF+2KLa/3A7js5X0oMasIXdlQe3Y99 JNBWcuRAQVbog0r6Du8DI4pMf1/deeUGLCSinScCpMHOGrglI8f9WUSeWIwaazqNPvEBJUPsJOV zEryoYmiRc8V5lBnhlWBSJBpkABfnbVSPoVzSbtEqqDWgCukZdCrj7Ep2GgpwweVt9L6sAHVPf3 Xn+tUsqE77Mf/ltzY0KPtV31HcZCdShDaDjbqdYs6VZ8OOJSiur78Z/RuF+bIOl7BFFOGwaltFm rY7Olxh+aT/LdsHQXHc+JdIv1M0o= X-Google-Smtp-Source: AGHT+IH6Hr1qwriJCC85ndlQ1bvKXxyAoAHlS6y7iTKbZ7H1N7faF/tVmb56NvKrfk6smujvQ/oQVgYTIUfR X-Received: by 2002:a05:6512:b90:b0:59a:10c1:8f27 with SMTP id 2adb3069b0e04-59b652bd49emr186687e87.6.1767647151238; Mon, 05 Jan 2026 13:05:51 -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 2adb3069b0e04-59b65ce9861sm24671e87.10.2026.01.05.13.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 13:05:51 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.49.34.222]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 90EBF341C73; Mon, 5 Jan 2026 14:05:49 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 8D437E41BCB; Mon, 5 Jan 2026 14:05:49 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe Cc: Joanne Koong , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH v7 3/3] io_uring/register: drop io_register_enable_rings() submitter_task check Date: Mon, 5 Jan 2026 14:05:42 -0700 Message-ID: <20260105210543.3471082-4-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260105210543.3471082-1-csander@purestorage.com> References: <20260105210543.3471082-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" io_register_enable_rings() checks that the io_ring_ctx is IORING_SETUP_R_DISABLED, which ensures submitter_task hasn't been assigned by io_uring_create() or a previous io_register_enable_rings() call. So drop the redundant check that submitter_task is NULL. Signed-off-by: Caleb Sander Mateos Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Joanne Koong --- io_uring/register.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_uring/register.c b/io_uring/register.c index 8104728af294..78434869270c 100644 --- a/io_uring/register.c +++ b/io_uring/register.c @@ -178,11 +178,11 @@ static __cold int io_register_restrictions(struct io_= ring_ctx *ctx, static int io_register_enable_rings(struct io_ring_ctx *ctx) { if (!(ctx->flags & IORING_SETUP_R_DISABLED)) return -EBADFD; =20 - if (ctx->flags & IORING_SETUP_SINGLE_ISSUER && !ctx->submitter_task) { + if (ctx->flags & IORING_SETUP_SINGLE_ISSUER) { ctx->submitter_task =3D get_task_struct(current); /* * Lazy activation attempts would fail if it was polled before * submitter_task is set. */ --=20 2.45.2