From nobody Mon May 25 08:10:48 2026 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 26B53243367 for ; Fri, 15 May 2026 14:58:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778857110; cv=none; b=QxkTLSzsMgRyUlvYm9h07SNbxuDbwypGSyeP2Sokg7d4AJbZumQXp+tQOYo9xXD9hAxn0G2WJK1ggPc1TCrebVq6uR8fxKAwuxQhzDzLH10zr5p6/kkb/HQJiRymVOATUNswv3JM1sYG1ZbZTpQgcTrf2tkzuYwaWGZkKrAXky4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778857110; c=relaxed/simple; bh=E1xx1uYoxK+eSCVWHUsVq/IguOxd3TLj+xysRTJERkQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NYiXkcoKzTuMFK9o9W3eGY4arPwqwJIEPpzorgoZQytoUl3I95ASPjcGjKQJjGA1o2ATM42AJj2J/gpWQyryuuRAYcx7a16s/JUNcsWjQ3v5U6cZHs3rCsoHQ0pRBak9kge55h4j82YeJxsijGDtxIWwlKmX3Jz3BCGpA9P+cuQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PDAnfSVr; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PDAnfSVr" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-8cbc593a67aso833782885a.2 for ; Fri, 15 May 2026 07:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778857108; x=1779461908; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0+nei0qxNlG/6SVkqADrmiSvLLb+6waS8I6r15019/8=; b=PDAnfSVrU9OUHCH0STDvIPOJmRymaf8I4D7D0/3cdx7Nh94rucmofMhBh1MZlaKj5J L/GBLIHg906/V/r/BHUsSKmv71mbxCpJjd3Ijviiy3G9Usq/tjqIA52GSp5WNVbuZBmz X6G0tnUXmmOXj8elA0thZqSXX0u1mEa5jEYEU7prPCMae+NrHDNcX7jeoWMq+ty/ayEk /Z3Vv6vsYY7eQuzU652tfxXN/6EdHZ+aMRkj5bSYVMAOcMwqoOgwGzykM6ESxB4I5are w5dEhem6l12rzFq7eJXx7djYbRp6VXZTaJT9a3uZdrXU4iT4H8hVGQ6IIbKJqcPdNw28 I0Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778857108; x=1779461908; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0+nei0qxNlG/6SVkqADrmiSvLLb+6waS8I6r15019/8=; b=TRcTRE0JWAytRpa3r++MlXvF5Zr3bdW02gM7299NQiiY052uXrek3skwxoG4tlozde 60v2m2ws6DQOAkwlKnbkqMZS54lXm/L1aBJ1SWj3WmVpWNphVw6UunqGmIRUH1qzDvjW GN6EgOs6ATM3sgq6x4MeLREQ7hn5XWuYSuGZoyptXACzejXSPg2w1JMOJ+8YGQx5d/FR E6jbNpj+G0WFSpKdIQvoh7ztJHjVuFJWQ+PCBaxCCL89d2YvFaX3swV4EWyg1ji8Rh5Z l/a06ie3m0BVE+VxM4Q1C1RaIWPpesQ3Bo009yKgwhgAmpt6C3DAmtPs4AQjFphDVFPE yRyA== X-Forwarded-Encrypted: i=1; AFNElJ9XeNiq40T6MUFH56s+tz+Fk3E3/bi4MvgtCqBD1g1s10w784PNddHjXqb/bfgI+q4ULk8vfhxs0Bpnrmw=@vger.kernel.org X-Gm-Message-State: AOJu0YwVn02NIEtm6qU+yF6Jh6asS2gOCZnhu+jnSFpbr8GB5F5FgKpq f+a7VKmu1JrikPR8/tYaT0dWvRoNVNzJw+vBDRlaKoqhsYqHuK6OwOd8 X-Gm-Gg: Acq92OGGK6KKu8+SQ6GbyUOLed6acvxCVYetY9+XeOIXKg/lmgbeXw51Gybm0NAgTvH ZAwFbsZQKKrghQS9UqePeTZfc0v9dBOzsvLb9iTKsWR4ZS29c7/UyCZlPNzFWQQ3MIdEX1cUk8Y rdeREn3NvP48x1BEUaq49V+fog4ywkLhXiMdQfvnHZa2/j+aV48ZgFCsQ2bG+MxTQZdLSHFsS2G WNmcnvnx7JatmdWlqfLn3pRSF9DWbKKa0ct1D4vTJ4R2eMnPTkflXhfBAOAQopCFEWfuN4JN8xZ pQ1i2WdDrHJfXj8cn8c8edfRROL7q3nDZThKyWKD8iQ0Ok223ISRAUGo8DixucYBfOs+mls3tSo ATQBnyC5zvlBeTwtn9obDvBx4x8eE05L6PUIHwCOZFsKcJAEAGaTC05GGUT9GawXMif8ZuhCvAR LB4jPf7swsPkWIzeAFuxWfVxFCLRdEictJX4xTFrOAMCoeYDNalR3zYVswN0iy0AKpl17NYOOpv JfIe5YcIV5Mi8MZU7HCdTdoHqWjNplWAeANfoN2OLw= X-Received: by 2002:a05:620a:4083:b0:911:1a2c:f953 with SMTP id af79cd13be357-911cd75d3e6mr700185285a.20.1778857108064; Fri, 15 May 2026 07:58:28 -0700 (PDT) Received: from server0.tail6e7dd.ts.net (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-910bcf3584esm550293385a.34.2026.05.15.07.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2026 07:58:27 -0700 (PDT) From: Michael Bommarito To: Jens Axboe , io-uring@vger.kernel.org Cc: Pavel Begunkov , Li Zetao , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] io_uring: propagate array_index_nospec opcode into req->opcode Date: Fri, 15 May 2026 10:58:11 -0400 Message-ID: <20260515145812.1241925-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 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" Commit 1e988c3fe126 ("io_uring: prevent opcode speculation") added array_index_nospec() to the local opcode in io_init_req(), but the sanitised value is not written back to req->opcode. The unconditional write at the top of io_init_req() stores the raw byte into the persistent field; the success path of the bounds check leaves it unchanged, and downstream consumers read the raw value. In io_uring/io_uring.c those consumers are io_issue_sqe(), __io_issue_sqe(), io_wq_submit_work() and io_prep_async_work() (all indexing io_issue_defs[]); io_clean_op(), io_req_defer_failed() and io_req_sqe_copy() (io_cold_defs[]); io_check_restriction() via test_bit() on ctx->restrictions.sqe_op; and the audit hook at the io_issue_sqe entry. io_uring/bpf_filter.c added in v7.0 extends this set with io_uring_populate_bpf_ctx() and __io_uring_run_bpf_filters(), indexing a heap-resident per-filter pointer array sized at allocation to IORING_OP_LAST. The kernel's spectre_v1 protection is per-site array_index_nospec() annotation, so a site missing the annotation is unprotected regardless of CPU vendor, microarchitecture, or microcode revision. A per-site array_index_nospec() was applied to the same class of gap in io_uring/fdinfo.c recently. Propagating the clamped opcode to req->opcode once, immediately after the existing array_index_nospec(), closes the remaining sites at the source without per-site clamps. The compiled change is one instruction (a single mov of the clamped byte to req->opcode); the cmp/sbb/and clamp triplet is unchanged. No functional change: array_index_nospec() is a no-op for opcodes in [0, IORING_OP_LAST), and out-of-range opcodes are still rejected at the bounds check above this assignment. Boot-tested under UML (x86_64 defconfig) by building stock and patched kernels and running a 54-test subset of liburing's test suite against each; pass/fail identical on both. Fixes: 1e988c3fe126 ("io_uring: prevent opcode speculation") Signed-off-by: Michael Bommarito Assisted-by: Claude:claude-opus-4-7 --- io_uring/io_uring.c | 1 + 1 file changed, 1 insertion(+) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 4ed998d60c09c..7b257a03ef84c 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1739,6 +1739,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struc= t io_kiocb *req, return io_init_fail_req(req, -EINVAL); } opcode =3D array_index_nospec(opcode, IORING_OP_LAST); + req->opcode =3D opcode; =20 def =3D &io_issue_defs[opcode]; if (def->is_128 && !(ctx->flags & IORING_SETUP_SQE128)) { --=20 2.53.0