Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69C1F346AC6 for ; Fri, 27 Mar 2026 02:18:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774577908; cv=none; b=Gw6B9vhYiDfGsEYuVquZn09GADnJMGtFiZyVG5Xdod5MIHbur9R70f5YXSpwYzm+0bx+LF5YKGLwjggC15NuRYd9PrCEpsX6nRnG3gzDWdCoyuk3qTsx0jsnNZMMCKM9Xvg2Na/tgsgYwqmkHZ1JEO3ssyO7pwKFK3j3vxp0N3M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774577908; c=relaxed/simple; bh=V2paLFxzlaRJBVM4Gv5VCShG8jC+vTGiEONfo2xBj7g=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=r4E6YuXY70uBGjer0VemgUZfN5whYQCRyBmZuogrBxKLykAXgFQdEIJmcFKvI9xIldKVGHp7jcWxaTRokaV7JJMKFHgA4j2FPGN7hAsrlbIJXOAn4toVx/m99jX85NhTB1d3em+XowBJPbaOstfeNsg4rL9Wmx1hiqNycwnm3vw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=carlini.com; spf=pass smtp.mailfrom=carlini.com; dkim=pass (2048-bit key) header.d=carlini.com header.i=@carlini.com header.b=tWgVCkSY; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=b/fnW9Zf; arc=none smtp.client-ip=103.168.172.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=carlini.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=carlini.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=carlini.com header.i=@carlini.com header.b="tWgVCkSY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="b/fnW9Zf" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 8B0001400280; Thu, 26 Mar 2026 22:18:25 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Thu, 26 Mar 2026 22:18:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=carlini.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to; s=fm3; t=1774577905; x=1774664305; bh=iOFN5K3RVjBjQS53+oJpb WyBOcTQQsip2+L54ScJ9C4=; b=tWgVCkSY40E60kJPbI6B0tR24si1RrEC/LKAV f9REDRM4iDQ+dTAnW3qH6VVIJXGXqLvBaF4tRolp44N75GMQe7xuwvpeJ35OuZ2I tSqMnwQCiQc5sEbcjy979P/est2j5wh1gO59xwUi16mSjUyOtto2SASpXrvs6p/C sXGGmXFFvxGHUoWxAB9UEAipD5jvlBT1VaO0Tcf/3FxJgO4RRq7aODSkty6hA3r5 pyseYF3DHoCDBmUWWIUXddJpjiBoFu6g22jWoRL8sUF3RipfLuO96nmiDkeXJdo0 Crt1i5uwb5ajcVVEHmmOAPrCDxHF82t4voZY+OzGxVRXThHLQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1774577905; x=1774664305; bh=iOFN5K3RVjBjQS53+oJpbWyBOcTQQsip2+L 54ScJ9C4=; b=b/fnW9ZfhXzlh41sLirxtv22rSTS6g27w9X3n33XtV3m7qxNt2H wzsklCN40lrNf0noVIXNlpnirPjkGnuTiVaLpThb5NtnlUjvPHnGeR6ccMLrcB8V jiiJv2pEkADqER8lnGxRv0SM/jUDxvBO0zatsdztZL6VwK8jtfVqnnihcUKWikth MUBq6wXc+I34u0IKhBJTMJrlmW1MSOIltjZ/YKw509PY6DN+27ivWYJzbLh9M6R+ a9ep+Bj5gU1f25vSkrSpsi7kHBCK9Qbf897uzfpx8SHURuFvDAPU2lgkQPjiE3Hw T5ANzFn7TA41gdkm043/l8lKYpD7jjYSWPA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefvdeltdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomhepnhhitghhohhlrghs segtrghrlhhinhhirdgtohhmnecuggftrfgrthhtvghrnhepjeelfeeuieduheehheefje ffvdetvdefuedttedvheefteffvdefveelheffgfejnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomhepnhhitghhohhlrghssegtrghrlhhinhhird gtohhmpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthho pehiohdquhhrihhnghesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegrgi gsohgvsehkvghrnhgvlhdrughkpdhrtghpthhtohepkhgsuhhstghhsehkvghrnhgvlhdr ohhrghdprhgtphhtthhopehnihgthhholhgrshestggrrhhlihhnihdrtghomh X-ME-Proxy: Feedback-ID: i78b949e2:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 26 Mar 2026 22:18:24 -0400 (EDT) From: nicholas@carlini.com To: io-uring@vger.kernel.org Cc: Jens Axboe , Keith Busch , Nicholas Carlini Subject: [PATCH] io_uring/fdinfo: fix OOB read in SQE_MIXED wrap check Date: Fri, 27 Mar 2026 02:18:23 +0000 Message-ID: <20260327021823.3138396-1-nicholas@carlini.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Nicholas Carlini __io_uring_show_fdinfo() iterates over pending SQEs and, for 128-byte SQEs on an IORING_SETUP_SQE_MIXED ring, needs to detect when the second half of the SQE would be past the end of the sq_sqes array. The current check tests (++sq_head & sq_mask) == 0, but sq_head is only incremented when a 128-byte SQE is encountered, not on every iteration. The actual array index is sq_idx = (i + sq_head) & sq_mask, which can be sq_mask (the last slot) while the wrap check passes. Fix by checking sq_idx directly. Keep the sq_head increment so the loop still skips the second half of the 128-byte SQE on the next iteration. Fixes: 1cba30bf9fdd ("io_uring: add support for IORING_SETUP_SQE_MIXED") Signed-off-by: Nicholas Carlini --- io_uring/fdinfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/io_uring/fdinfo.c b/io_uring/fdinfo.c index 80178b69e05a..6b5609f1db60 100644 --- a/io_uring/fdinfo.c +++ b/io_uring/fdinfo.c @@ -119,12 +119,13 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) sq_idx); break; } - if ((++sq_head & sq_mask) == 0) { + if (sq_idx == sq_mask) { seq_printf(m, "%5u: corrupted sqe, wrapping 128B entry\n", sq_idx); break; } + sq_head++; sqe128 = true; } seq_printf(m, "%5u: opcode:%s, fd:%d, flags:%x, off:%llu, " -- 2.39.5