From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 906FC3C140F; Wed, 20 May 2026 18:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300776; cv=none; b=RF0JUWvbot5aoc3opn7GziwBlooZCAsR/u+X/4TQrExPwJa9icBDlFu430J7ogEJRFY2U0omjVEaSfAtQoPaGO2n8oeE+RPziOo7IkgAY1I8oiAIgwjGzwmt7S5d3I8P21pap1z63YBH66HG1v5ambIMNTINRAAgMT4N2DKH11k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300776; c=relaxed/simple; bh=VpNS4egkkJeoB9wzrPYbhA7xndhI13SXr8yjjLzLhyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h6HA1sxvEqp5jv55J78zcX9jdoOkphNeyQxdggJd9P8m9SWfe5JybxYuNY7Pi44x2F+eNXtNhrHfFik/mhusUOuBNMQu/ZhTo2yd9dt+yUTWMQfau7lzjYQGTK8/jSxL54tXVt/WKz3kf5nWatfCWWmzQv7e+CIF62BG5nVJOEo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=EQmPpmxd; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="EQmPpmxd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF9D01F000E9; Wed, 20 May 2026 18:12:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779300775; bh=pHZXJWZjm/bYrA/O1IkGcAl9iiuSq6iJfLCTDWKwDqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EQmPpmxdE4XAOQcG8euRXSq5zhmZ6MS22wCCrPAskA3w4UXiAK00asD8aBFfp0Hxt 2HkprSaypPUg8ClI/LsD6/KJ7x5E/jNDb1t23wqjw2bjogS5rjBHcDUYP+62IjX6hT syuUrpvKSn3i+NasDHbRrK3TFF0LMqI6dUs1xrHE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thomas Huth , Ard Biesheuvel , Sasha Levin Subject: [PATCH 6.12 261/666] efi/capsule-loader: fix incorrect sizeof in phys array reallocation Date: Wed, 20 May 2026 18:17:52 +0200 Message-ID: <20260520162116.875132742@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162111.222830634@linuxfoundation.org> References: <20260520162111.222830634@linuxfoundation.org> User-Agent: quilt/0.69 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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Huth [ Upstream commit 48a428215782321b56956974f23593e40ce84b7a ] The krealloc() call for cap_info->phys in __efi_capsule_setup_info() uses sizeof(phys_addr_t *) instead of sizeof(phys_addr_t), which might be causing an undersized allocation. The allocation is also inconsistent with the initial array allocation in efi_capsule_open() that allocates one entry with sizeof(phys_addr_t), and the efi_capsule_write() function that stores phys_addr_t values (not pointers) via page_to_phys(). On 64-bit systems where sizeof(phys_addr_t) == sizeof(phys_addr_t *), this goes unnoticed. On 32-bit systems with PAE where phys_addr_t is 64-bit but pointers are 32-bit, this allocates half the required space, which might lead to a heap buffer overflow when storing physical addresses. This is similar to the bug fixed in commit fccfa646ef36 ("efi/capsule-loader: fix incorrect allocation size") which fixed the same issue at the initial allocation site. Fixes: f24c4d478013 ("efi/capsule-loader: Reinstate virtual capsule mapping") Assisted-by: Claude:claude-sonnet-4-5 Signed-off-by: Thomas Huth Signed-off-by: Ard Biesheuvel Signed-off-by: Sasha Levin --- drivers/firmware/efi/capsule-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 0c17bdd388e12..bbddeb6a09552 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -67,7 +67,7 @@ int __efi_capsule_setup_info(struct capsule_info *cap_info) cap_info->pages = temp_page; temp_page = krealloc(cap_info->phys, - pages_needed * sizeof(phys_addr_t *), + pages_needed * sizeof(phys_addr_t), GFP_KERNEL | __GFP_ZERO); if (!temp_page) return -ENOMEM; -- 2.53.0