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 6FA753FD959; Fri, 15 May 2026 16:05:46 +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=1778861146; cv=none; b=HrFCKZnsCSw3oQHFOFmNorLxIVeZO/mLoCAbvWXoR+DUrefUv/3jFA9ocyYKKVMIMW24sdVsiedmHdkSjCGam0o+VDQ1MXe90nIAYrdcAqsaJvZwuOTpFJtykdVOOkrFKqn6ba2+uYf4gt24eYHqzHAg+6gXrZubO0z3gWi1UmA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778861146; c=relaxed/simple; bh=qz1PcBJ62sSPZjA3zEqX+PJ01FVVRYtMQdshH8hFUAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=teUNHx20YrCt0k4gRR7qidj6futir1Cma9ZHHE2jL9Yz2qqjSc85Vrqn++TLJAqbbwNGK5Vo2EMvVeUABOK8iQmsEtGNp8K8tR5qX1lqQ0BqpvFwdsaSDeB5Nfn2t1zBVYRqVo7+5bxWrP+BauckLQP3Uw6/wEoMvlvaeNiLwwc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IA1NsXjp; 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="IA1NsXjp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C42EC2BCFA; Fri, 15 May 2026 16:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778861146; bh=qz1PcBJ62sSPZjA3zEqX+PJ01FVVRYtMQdshH8hFUAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IA1NsXjpbtHDp9mJGL3uZrsB9zVe8IMe8wJyL2yYjoE/7MHDXFarUraP6Q4YCGhJ+ 9khvCOZit7LzFEVchEbRYDpWU7JXeTaIvxNmAAXL+qt67yUaF1P1XadLbF2461ER/i lX+7MLUUG5dC9wmwfU2Hkhp6z7fbpkZJTdY5PX/c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tudor Ambarus , Takahiro Kuwano , Michael Walle , Pratyush Yadav , Miquel Raynal Subject: [PATCH 6.6 217/474] mtd: spi-nor: debugfs: fix out-of-bounds read in spi_nor_params_show() Date: Fri, 15 May 2026 17:45:26 +0200 Message-ID: <20260515154719.705434112@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154715.053014143@linuxfoundation.org> References: <20260515154715.053014143@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tudor Ambarus commit e47029b977e747cb3a9174308fd55762cce70147 upstream. Sashiko noticed an out-of-bounds read [1]. In spi_nor_params_show(), the snor_f_names array is passed to spi_nor_print_flags() using sizeof(snor_f_names). Since snor_f_names is an array of pointers, sizeof() returns the total number of bytes occupied by the pointers (element_count * sizeof(void *)) rather than the element count itself. On 64-bit systems, this makes the passed length 8x larger than intended. Inside spi_nor_print_flags(), the 'names_len' argument is used to bounds-check the 'names' array access. An out-of-bounds read occurs if a flag bit is set that exceeds the array's actual element count but is within the inflated byte-size count. Correct this by using ARRAY_SIZE() to pass the actual number of string pointers in the array. Cc: stable@vger.kernel.org Fixes: 0257be79fc4a ("mtd: spi-nor: expose internal parameters via debugfs") Closes: https://sashiko.dev/#/patchset/20260417-die-erase-fix-v2-1-73bb7004ebad%40infineon.com [1] Signed-off-by: Tudor Ambarus Reviewed-by: Takahiro Kuwano Reviewed-by: Michael Walle Reviewed-by: Pratyush Yadav Signed-off-by: Miquel Raynal Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/spi-nor/debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/mtd/spi-nor/debugfs.c +++ b/drivers/mtd/spi-nor/debugfs.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include #include #include @@ -92,7 +93,8 @@ static int spi_nor_params_show(struct se seq_printf(s, "address nbytes\t%u\n", nor->addr_nbytes); seq_puts(s, "flags\t\t"); - spi_nor_print_flags(s, nor->flags, snor_f_names, sizeof(snor_f_names)); + spi_nor_print_flags(s, nor->flags, snor_f_names, + ARRAY_SIZE(snor_f_names)); seq_puts(s, "\n"); seq_puts(s, "\nopcodes\n");