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 EFB39270545; Wed, 20 May 2026 18:36:43 +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=1779302205; cv=none; b=QVEfc5Ef9tPosExJjnjEUVIdBemQxGPJToTWfIVJwV9Hs9qzQyxUxKT87SMvn0c1BXkqy+GdmqoGAoyZBy4nUTaEvW+1I7olT08qP4yko4FNsTrPv//M1tEx1pJvNp6DiBAnleeFtNRW4H9qWnEtekuUP7cmHqNVFj0808qHiUU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779302205; c=relaxed/simple; bh=F9ZLRQPc8v8YqgXcPTWqSdVOmitcy3t+cxN6SvwXmuw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZNn3ZmVpokmJog9RZf9Go6g8EAvQ4Bn7wvRHbl+Y7wuTbHTQI7D4PFw7QtzGnkdjokr5dwzM5CkzSnOPn0xjpitMZMpkR7LTc8XdShw0pra4x5xazE9BILNWACzVjmJCHGPp2adhwgLOL9glAhHdPWs9Jt5M3FUhUXuMQ7RSUtY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UQNUpSyd; 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="UQNUpSyd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61E3E1F000E9; Wed, 20 May 2026 18:36:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779302203; bh=rWkQTRUtcDT1APBH4KT9y8tyXDSytWdUM8/anXiykf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UQNUpSydGGg9Vsq9HeJTK+0i8eCiZMKovC5Q6nzssUoDUI50kvszTsiX53/NN9qXf YJcg6Yxo+jifneG5Smk90V/Ojx/aA0RmmizuSemIJ1rcTQn7/g3n3R5IVgZ/ceI6RE tpmjTM2buRZCslw9NQgPfVeuDdxtQo9eJ0MeghGE= 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.6 179/508] efi/capsule-loader: fix incorrect sizeof in phys array reallocation Date: Wed, 20 May 2026 18:20:02 +0200 Message-ID: <20260520162102.516967804@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162058.573354582@linuxfoundation.org> References: <20260520162058.573354582@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.6-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