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 C86152F6931; Sat, 12 Sep 2026 16:32:23 +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=1789230745; cv=none; b=CqAi7oz3uP/1BYm3aP9RLG2/WHjRMpMVrGEsM+hYEJGf80xjS9yvX2MzZRmBuy0LvSdVzQVcITioaFakrvwjQPLWzSsPEYbK8kgkLqs7X0CjMVuqeuo+2Bgyw77ilCnQB1m2b/nFoLC83mRQPC1je9x01BYQ0jolKEOdK8qQsG8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789230745; c=relaxed/simple; bh=iY75Ei+HHODYEGNtMADB2li8NMqVw57uqzIXQNVDrIw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TjR/NcJQTkgdmKQZIVJfpgImxELDvDROOt+ocwpQrTHcc32J0mXlK+JljpzAwHlKYxZSwB45BH9VjCDdJwtCBUVYFb9DeBcQQZU0BoD1gs3cL3G0ryHh3QlUK+YITvkn+ILlhAKr8ng6wyHbFhaP5vN34mVda7Uz7fUAtY3xyyk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mpNmakvy; 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="mpNmakvy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75CFF1F000FF; Sat, 12 Sep 2026 16:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789230743; bh=gSAzHkLaCV91eLdmg2c2+axFpdxpETM33vUwrtX+n/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mpNmakvyUzpbJEpXojoDBsUIGJNfM9ygeI+TO+2rvdtf79s7PTkZQpb9uWfpM5RPx EU8V06RYYwcLxL25FqaPL0EQRiIo2/phW/LX2qnTvgqpCYsTp1vBDEcyUHQL1fq/D3 2dtIkZhplrNONjY/s2yB2HNi1p2jCa/93CqETkdE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Titouan Ameline de Cadeville , Julius Werner , Tzung-Bi Shih , Sasha Levin Subject: [PATCH 6.1 0830/1191] firmware: google: Add bounds checks in coreboot_table_populate() Date: Sat, 12 Sep 2026 08:59:18 +0200 Message-ID: <20260912065606.906808354@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@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: Titouan Ameline de Cadeville [ Upstream commit 7b1a1af4556a4f95ef273e91435fe804cbfcd223 ] coreboot_table_populate() iterates over firmware-provided table entries with no validation that the entries stay within the mapped memory region. A corrupt table with a large `entry->size` advances `ptr_entry` past the mapped region, causing an out-of-bounds read on the next iteration. Add a check before dereferencing `ptr_entry` to ensure the entry header is readable, and a second check after reading `entry->size` to ensure the full entry stays within the mapped region. Pass `len` from coreboot_table_probe() into coreboot_table_populate() to make the mapped region size available for validation. Signed-off-by: Titouan Ameline de Cadeville Reviewed-by: Julius Werner Link: https://lore.kernel.org/r/20260426214739.117131-1-titouan.ameline@gmail.com Signed-off-by: Tzung-Bi Shih Stable-dep-of: a58a57a1076f ("firmware: coreboot: Validate table bounds") Signed-off-by: Sasha Levin --- drivers/firmware/google/coreboot_table.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c index f3694d3478019..95fc2e4d0cccf 100644 --- a/drivers/firmware/google/coreboot_table.c +++ b/drivers/firmware/google/coreboot_table.c @@ -81,16 +81,20 @@ void coreboot_driver_unregister(struct coreboot_driver *driver) } EXPORT_SYMBOL(coreboot_driver_unregister); -static int coreboot_table_populate(struct device *dev, void *ptr) +static int coreboot_table_populate(struct device *dev, void *ptr, resource_size_t len) { int i, ret; void *ptr_entry; struct coreboot_device *device; struct coreboot_table_entry *entry; struct coreboot_table_header *header = ptr; + void *ptr_end; + ptr_end = ptr + len; ptr_entry = ptr + header->header_bytes; for (i = 0; i < header->table_entries; i++) { + if (ptr_entry + sizeof(*entry) > ptr_end) + return -EINVAL; entry = ptr_entry; if (entry->size < sizeof(*entry)) { @@ -98,6 +102,9 @@ static int coreboot_table_populate(struct device *dev, void *ptr) return -EINVAL; } + if (ptr_entry + entry->size > ptr_end) + return -EINVAL; + device = kzalloc(sizeof(device->dev) + entry->size, GFP_KERNEL); if (!device) return -ENOMEM; @@ -154,7 +161,7 @@ static int coreboot_table_probe(struct platform_device *pdev) if (!ptr) return -ENOMEM; - ret = coreboot_table_populate(dev, ptr); + ret = coreboot_table_populate(dev, ptr, len); memunmap(ptr); -- 2.53.0