Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795039432; b=Augmk1ceyLwvsaA7uvxX/2xbR7cFiRvPVXtpifzLGHu1Nm/8Yvq0Sl4YCC/7th3PgqSH ztaIv2KOktGduIbWqa4948/I9KtVAZicktKQbwTY2oLCmmxFnQgWTKn+7G8yfaSFpl6wy yPpdw9cLKxdLwcFDvhHQYP96vnSmq1CsCyGCf/b1QgIpotKhf7A1tXiPQszOhicKfrvFw fcJrBI80D+BB2oamlnMMJhanH5cSUdPpXj3kBFl8JD0Gxas6ScSt78L3EuYE77VBgR3Lf 9ta1+uBcqt334vWWh2QmRCaYnLCodj143vCmCCaLMIoHg4iFsxujgsDr4wMsN6jXMfA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795039432; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=kELNdUALTDgXKlfqM3n1hsKK279PKrrxn7QhF5lXEnI=; b=2juEjeG/3fC7qCSsQ8qeCOYdXYo2QTxf1g6SRgNkY5rMb36HkifZWAJ3LOq6WCXoEoZP 0iEA1D/VMWem0dXVZk01qzujsi8iMuTyBXVPw5+s8HdBsrVBoiWhmAitOWyp6Q2/pN8Jr RVvO9p1Ch6SpznKQAc0QQVw5eS1yXQ3fn6tUGzSL0ZbjKrPkFScMoV0SIPQOE7JnBBeD+ SJ1ikxW5oIsBqewbuXQXnDGxeVlEsUE0UYXzM/jNu3wIpmh+AAe4tqVEoN/0JZl3fa4sE 8pCKqzJav3UEjqI54d+RSLJ5IK0sDsGP26JIUDlospBzET9rkcwPpY4n0KNQwx6s5jg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ikrsUbBQ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 222E4606A31C; Wed, 18 Nov 2026 22:03:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ikrsUbBQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E6381F000C5; Wed, 18 Nov 2026 22:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795039432; bh=kELNdUALTDgXKlfqM3n1hsKK279PKrrxn7QhF5lXEnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ikrsUbBQOqTJIU76gNTXGRevREj9cHoJyzpR+VZ5KqIU9Ig+GXIQzdX34VZA8+aUW aN3aEh9AGPF9vGpCG6MDKYDnSedqYVPBAXdbD4OOg9Qq9VJp4Zq8jM7VVEFyBb5TN5 yK23WPDEPgKy90eJu7JcRA/z8Wu/WtMDjNOhHrfY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, sashiko-bot@kernel.org, Hanjun Guo , Shuai Xue , Dave Jiang , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 6.6 2057/3318] efi/cper: Reject CPER records with an out-of-range error_data_length Date: Wed, 18 Nov 2026 15:44:39 +0100 Message-ID: <20261118150423.774538301@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Jiang [ Upstream commit a5a612cd3eecbadf135df1e9b2b40bc9f4c28f1c ] cper_estatus_check() sizes each section with acpi_hest_get_record_size(), which adds the firmware-controlled u32 error_data_length to the header size as a signed int (see ). A value in the top sizeof(*gdata) bytes of the u32 range wraps the sum small rather than large, so it slips past the "record_size > data_len" check: against the 72-byte v300 header, 0xffffffb9 sizes the record at 1 and acpi_hest_get_next() walks it a byte at a time, off the end. 0xffffffb8 sizes it at 0 and loops forever. Use check_add_overflow() to reject a sum that will not fit the int those helpers return, since the walk advances by that value. That subsumes the "acpi_hest_get_size(gdata) > data_len" test above it, because record_size is never smaller than the header. The later "len < sizeof(*foo)" guards rely on this per-section upper bound; they are lower bounds only. Reported-by: sashiko-bot@kernel.org Closes: https://sashiko.dev/#/patchset/20260714231835.303081-1-dave.jiang@intel.com?part=1 Fixes: 45b14a4ffcc1 ("efi: cper: Fix possible out-of-bounds access") Reviewed-by: Hanjun Guo Reviewed-by: Shuai Xue Signed-off-by: Dave Jiang Link: https://patch.msgid.link/20260904172337.1409775-2-dave.jiang@intel.com Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/firmware/efi/cper.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index 9d0f0bf3067cc..d922b378fa4cd 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -728,7 +728,7 @@ EXPORT_SYMBOL_GPL(cper_estatus_check_header); int cper_estatus_check(const struct acpi_hest_generic_status *estatus) { struct acpi_hest_generic_data *gdata; - unsigned int data_len, record_size; + unsigned int data_len; int rc; rc = cper_estatus_check_header(estatus); @@ -738,10 +738,18 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus) data_len = estatus->data_length; apei_estatus_for_each_section(estatus, gdata) { - if (acpi_hest_get_size(gdata) > data_len) + int record_size; + + /* + * The helpers sum these as a signed int, so a + * huge error_data_length wraps small rather than large and the + * walk then advances by that wrapped value. Reject a size an + * int cannot carry. + */ + if (check_add_overflow(acpi_hest_get_size(gdata), + gdata->error_data_length, &record_size)) return -EINVAL; - record_size = acpi_hest_get_record_size(gdata); if (record_size > data_len) return -EINVAL; -- 2.53.0