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 950323603F7; Wed, 20 May 2026 17:31:39 +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=1779298300; cv=none; b=IBNO7iTSlzC81Prq1eQeyvvC6g+PNQI3m5oNomFBNvdKg15FKJVNGqAF9ELRy99W/kVjnBjJptbiIT8MsfxdeygtbjD9+MT9yhTYjcUab4eocVm/i1fD7MiKT4ceRVTmuk0QtBXb4tXAhov1mn1IvujK5jkdHpSHkjhMZxHc6vA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779298300; c=relaxed/simple; bh=rbgHuIYgWa+306nHBiXjokxL+OgLxh5FZ57/moufJ9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ANHpbcqhs3+NWiuH1+0BaLS7qLQxXNbSGPh2US5j2ZpnHoUs/v9Epi4y4cTWRSUzDbdf1z+q00oueGT9VOjR6qNqW+n+zu5y4PpqjOfUFJhchQ4zMxSqHbPG4EzsiXZJIneOOEPTlw1gOb+N690B/384WC+EK2nK/jHTAIySRhY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wDD2dGE3; 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="wDD2dGE3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 072B51F000E9; Wed, 20 May 2026 17:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779298299; bh=ngNseTWZRwUFD6VA4GhPEGo7Re/wKcmco6H/DArFXo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wDD2dGE3LwErOnqGaqy33oXzf+4+/dohXQtARBBoHDRxoUxLsDcraI9afL40+Yg3Z 2FdTVO3lRcyOFNC2s0SqT3+pIsZ9I1J0UDq8wcJ1XsKaG6/FMpTqmKnPOKDWau0CBl sAgWrCbVuo+CWj1O+vIowgA0E58D93ogwuC1p07w= 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.18 359/957] efi/capsule-loader: fix incorrect sizeof in phys array reallocation Date: Wed, 20 May 2026 18:14:02 +0200 Message-ID: <20260520162142.314928140@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162134.554764788@linuxfoundation.org> References: <20260520162134.554764788@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: 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