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 D530F330B2A; Mon, 29 Dec 2025 16:21:27 +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=1767025287; cv=none; b=DqNN06PMsJc+P832a25yi17WvNEKZd1JX0Y5gRptrx1kmSQwwcbk93CtcoKlm9SlUYHEE2/xr8jAUc5s2+8Xjwi9gjbq/z+as/GagqAQmmgMo8cvpaPInyfcsKS62xfcIh0DhTH9FlnIQpmTRYF+dol/XrYqG87/6z30Ihk3M6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767025287; c=relaxed/simple; bh=Q24UvHqexRt0vOvrNmFBb779AaHI8ttcJYzei96uy90=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jpg7oGVXKkIcHcEGLxaX5RtSqr6w/NY0891P4GjHEpbmIswHyXPApFghk9nbL3LvkBHaRRQK+FxvyLfmg9WceilpFl3gCIt3IqfIQdzI+MvraTWbNJiv7upDbiGlVvSiAGVJHxbrhJB6G2/UqQGkICjoPvPmW+Xxyh4n20WNkGE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HhgTnZxt; 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="HhgTnZxt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60A84C4CEF7; Mon, 29 Dec 2025 16:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767025287; bh=Q24UvHqexRt0vOvrNmFBb779AaHI8ttcJYzei96uy90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HhgTnZxti+2wCjfR5HKLAg4IFDCrk1bS6FLjXfl1BQRj9oecIh+plRRenEIcviw5B i8ZgKynEoRTJT9YHWRTsLyZl0ulUzsTy4qKqlOrB8VZimxdUlqOVbalujNLWv4o4+f K0C2ZqAy4wfH77Jh/SDkDM2XrR7A49iF7gLe8iGw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christophe Leroy , Sverdlin Alexander , Mark Brown Subject: [PATCH 6.18 159/430] spi: fsl-cpm: Check length parity before switching to 16 bit mode Date: Mon, 29 Dec 2025 17:09:21 +0100 Message-ID: <20251229160730.213992014@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251229160724.139406961@linuxfoundation.org> References: <20251229160724.139406961@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christophe Leroy commit 1417927df8049a0194933861e9b098669a95c762 upstream. Commit fc96ec826bce ("spi: fsl-cpm: Use 16 bit mode for large transfers with even size") failed to make sure that the size is really even before switching to 16 bit mode. Until recently the problem went unnoticed because kernfs uses a pre-allocated bounce buffer of size PAGE_SIZE for reading EEPROM. But commit 8ad6249c51d0 ("eeprom: at25: convert to spi-mem API") introduced an additional dynamically allocated bounce buffer whose size is exactly the size of the transfer, leading to a buffer overrun in the fsl-cpm driver when that size is odd. Add the missing length parity verification and remain in 8 bit mode when the length is not even. Fixes: fc96ec826bce ("spi: fsl-cpm: Use 16 bit mode for large transfers with even size") Cc: stable@vger.kernel.org Closes: https://lore.kernel.org/all/638496dd-ec60-4e53-bad7-eb657f67d580@csgroup.eu/ Signed-off-by: Christophe Leroy Reviewed-by: Sverdlin Alexander Link: https://patch.msgid.link/3c4d81c3923c93f95ec56702a454744a4bad3cfc.1763627618.git.christophe.leroy@csgroup.eu Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-fsl-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -335,7 +335,7 @@ static int fsl_spi_prepare_message(struc if (t->bits_per_word == 16 || t->bits_per_word == 32) t->bits_per_word = 8; /* pretend its 8 bits */ if (t->bits_per_word == 8 && t->len >= 256 && - (mpc8xxx_spi->flags & SPI_CPM1)) + !(t->len & 1) && (mpc8xxx_spi->flags & SPI_CPM1)) t->bits_per_word = 16; } }