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 3EE8B263F44; Sat, 30 May 2026 17:15:57 +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=1780161358; cv=none; b=ne+vhoGu4U2x0Sw0PxnGjLxsHo/lPDoyxXJt7IshcmX/24ZImdT6S5GAJBJnsJQlCT0A3A2+xVsbJqRtoeqEAy3Sbjprt2KlSD71jiEwvOTQ5tatmvO+vR9YnKplihFgEzxrJaHmDSkHsQvMj6Nt/h+lqfk8jqrbXjqteD2g1g4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780161358; c=relaxed/simple; bh=5MzSLSlJoDxcjzj5f3U8hzAzhVAPcmlHIl59JYskWAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h8leIJ8elU+gk4PBTBI6xZSA+gYBk7/7f1/OKxccybE5YjenQyx4W+wHHGzEaXHMuiikfHGAkHtZlTQcKcew4DbbaDxIhI3rysNR58jPebQixJbdUioFaVEKDassFf6ffCH9opbxb0UDs/fZ4cCc03RVyNoNVRz3G8cgygWdDyo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xiV57p9a; 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="xiV57p9a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 847701F00893; Sat, 30 May 2026 17:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780161357; bh=HJL0oRDNkrVKy9+P4I7/7V2FTt4kjuKihtyTPemRcGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xiV57p9ahj9oMZJWBZZOa8MH03IczbEe6bzfSpYcLBEzkW8ABYe/6ckQ56JI5LQ88 x9xru02IZ6XIZPQWawAjBkKK9wtbHvhgSeeXlqhN4Q31KdqLOaUHWljb6Gu51B6fJg kmyhapk0l+hK3jC+dUVXdLYthKgSYq8oBv5riUBs= 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.1 570/969] efi/capsule-loader: fix incorrect sizeof in phys array reallocation Date: Sat, 30 May 2026 18:01:34 +0200 Message-ID: <20260530160316.140098180@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@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.1-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 97bafb5f70389..c6a8bdbcae71b 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