From nobody Sun Feb 8 16:50:42 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 --- 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