From nobody Mon Dec 1 22:04:04 2025 Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) (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 50421235072 for ; Thu, 27 Nov 2025 14:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764252155; cv=none; b=pxnGNgnCYdjqp/tRE+8KXJIXehMCWCAkxy2ULrdHBJqNZl7vmBCho9JPmPzTp23g4XPqBYk4RzpGOXM2SXPehy4yC9qIILHRqfmE/naI+/JbxtFWd6i6ZahJEbRz5Y/uopxc6ByT3FpjBcFsttjIEMnxZ4WbjTNZVqCtqF7uHig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764252155; c=relaxed/simple; bh=5PX/iIDfuyyYqIcNb75539//OPviUA5Wl1Nt5gOSfbI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=SiljAEwvFgceuw9+NvVP7tGTH4RfNfGhqkhcJMeTJ2fbXcuK++xgPXZThCkQQZ02pUd8FX31Ih6hHFlhYZ4TV1gDnGiE3ZRMj/a4xT/PvBlKO2Q9CB2BDfMm2IPSNRkrsWxhZX2TpdznIpmPQy3ID0BEBZcVa7H/2MaemEQOJKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ECHHtHMT; arc=none smtp.client-ip=95.215.58.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ECHHtHMT" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1764252141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=t9sx4anvo4lGCsssDz1Ke/5DwhTNNf3DFzIUDPTugwc=; b=ECHHtHMTmmEI/ypGNIVfPDMrf26ZG8D1mUJsBi2cPzS4zFV3uvJna68XQjf7o/wiw+E2XM ZAs4Qp1KItICUFe2dNrDoD6OP2yDWmJMAV3SpaVv1WNeSzHEQst35NgI9V2dK5dlemuPtH VzLEXjs7rUvLYpzWaY8TWpQaU+t+Vjg= From: Thorsten Blum To: Kristen Accardi , Vinicius Costa Gomes , Kanchana P Sridhar , Herbert Xu , "David S. Miller" , Tom Zanussi Cc: Thorsten Blum , stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] crypto: iaa - Fix out-of-bounds index in find_empty_iaa_compression_mode Date: Thu, 27 Nov 2025 15:01:57 +0100 Message-ID: <20251127140158.173840-1-thorsten.blum@linux.dev> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The local variable 'i' is initialized with -EINVAL, but the for loop immediately overwrites it and -EINVAL is never returned. If no empty compression mode can be found, the function would return the out-of-bounds index IAA_COMP_MODES_MAX, which would cause an invalid array access in add_iaa_compression_mode(). Fix both issues by returning either a valid index or -EINVAL. Cc: stable@vger.kernel.org Fixes: b190447e0fa3 ("crypto: iaa - Add compression mode management along w= ith fixed mode") Signed-off-by: Thorsten Blum Acked-by: Kanchana P Sridhar --- drivers/crypto/intel/iaa/iaa_crypto_main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/in= tel/iaa/iaa_crypto_main.c index 23f585219fb4..8ee2a55ec449 100644 --- a/drivers/crypto/intel/iaa/iaa_crypto_main.c +++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c @@ -221,15 +221,13 @@ static struct iaa_compression_mode *iaa_compression_m= odes[IAA_COMP_MODES_MAX]; =20 static int find_empty_iaa_compression_mode(void) { - int i =3D -EINVAL; + int i; =20 - for (i =3D 0; i < IAA_COMP_MODES_MAX; i++) { - if (iaa_compression_modes[i]) - continue; - break; - } + for (i =3D 0; i < IAA_COMP_MODES_MAX; i++) + if (!iaa_compression_modes[i]) + return i; =20 - return i; + return -EINVAL; } =20 static struct iaa_compression_mode *find_iaa_compression_mode(const char *= name, int *idx) --=20 Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4