From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 936C3222D52; Thu, 12 Dec 2024 16:48:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734022131; cv=none; b=ssFsIPIRHpfNPope+kHWLMvGHCUewqAtJ8l5Bj9CiYmvEiLS03DcSBgBD7y3oAWL0LLHTmoCKUdJvob0edNi7LlgXsxpQTYfciRYReI2E22hvPxK4m/nMcIhYmdJE/8rbznDakcqzdHrUrI88AQzh5jtSvxTVbrLU23plEXXk1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734022131; c=relaxed/simple; bh=h95J9gJlQQq/H+f0bDtUvJPuTL6T1L71nw80ncYS3jI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R+MKwWAN1iLvbsYna5sYEiiLA85ApUJEnysXL4i4zVBsLfCfWErYP3y7JINXnyzDN25FFoA5LXHCBkJ+CwdRIdIvAnpa368HzBs0Jj/Vo7nhqrMRy4+ItDL10EpV6lOvpO5hSy3K5Y7HQXXfkTLo76mIISZE+o6GCbrB0m+8cTc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bBCWloWd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bBCWloWd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BB3FC4CED3; Thu, 12 Dec 2024 16:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734022131; bh=h95J9gJlQQq/H+f0bDtUvJPuTL6T1L71nw80ncYS3jI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bBCWloWdVURI7/yGrvcreUC0KO0aw7wr78WoLsR85Y23SuEAQPcWaeXPJbOqWfLj2 my6B7+HaaUOcqJxwGeyh5cx8P4/pJKpfo323cIN7A8VixU0h+Wglw5e0GXZXyC7kko 3g3DPstgHzmThFqK/Xewou3uKHdvwwlbDzdsORaw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Breno Leitao , Mark Brown , Sasha Levin Subject: [PATCH 5.15 127/565] spi: tegra210-quad: Avoid shift-out-of-bounds Date: Thu, 12 Dec 2024 15:55:22 +0100 Message-ID: <20241212144316.505122199@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144311.432886635@linuxfoundation.org> References: <20241212144311.432886635@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Breno Leitao [ Upstream commit f399051ec1ff02e74ae5c2517aed2cc486fd005b ] A shift-out-of-bounds issue was identified by UBSAN in the tegra_qspi_fill_tx_fifo_from_client_txbuf() function. UBSAN: shift-out-of-bounds in drivers/spi/spi-tegra210-quad.c:345:27 shift exponent 32 is too large for 32-bit type 'u32' (aka 'unsigned int') Call trace: tegra_qspi_start_cpu_based_transfer The problem arises when shifting the contents of tx_buf left by 8 times the value of i, which can exceed 4 and result in an exponent larger than 32 bits. Resolve this by restrict the value of i to be less than 4, preventing the shift operation from overflowing. Signed-off-by: Breno Leitao Fixes: 921fc1838fb0 ("spi: tegra210-quad: Add support for Tegra210 QSPI controller") Link: https://patch.msgid.link/20241004125400.1791089-1-leitao@debian.org Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-tegra210-quad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c index 7967073c13545..3432058b0a7bd 100644 --- a/drivers/spi/spi-tegra210-quad.c +++ b/drivers/spi/spi-tegra210-quad.c @@ -298,7 +298,7 @@ tegra_qspi_fill_tx_fifo_from_client_txbuf(struct tegra_qspi *tqspi, struct spi_t for (count = 0; count < max_n_32bit; count++) { u32 x = 0; - for (i = 0; len && (i < bytes_per_word); i++, len--) + for (i = 0; len && (i < min(4, bytes_per_word)); i++, len--) x |= (u32)(*tx_buf++) << (i * 8); tegra_qspi_writel(tqspi, x, QSPI_TX_FIFO); } -- 2.43.0