From mboxrd@z Thu Jan 1 00:00:00 1970 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=1795015601; b=AYij5dT7hcnr5rT3c56bbrvC2p2lMGijN6JzpcWoyg5XE80YbZB11Zn1JSMrERfG2pnr MGLqyLmJEwlhJCOCHh9mTzqLKHjh2UfgXf3W3J2JpTCUCzVxUoI/mj6/O6XxMnC2p8vLh ug0XFPrNUFi8U6q3uhS1T7xBkSukWFO+e2tipyOSqdM3DAcO85ZAByA8vHd7mYmFReMDu 9H/ov9mYrBIDGR/KBC2s2E3ffuaFG1jet3dLqbj+ikzuNaKVx4T4kNTQLiOMjPeMnVdyO frzYAFo938v8kU6CvlrDcCTMBsLiG/06socks8eECrz+W9eAkj/5NuJ6uQ440KUnA2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795015601; 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=v5ZfLTX+QiY0avi18ZpwEB5Txc9lts2ZKubmfTDMZok=; b=HqJIVd09ZP7hJpqUIydUVAJ5Qlv3/qXL0iUfAc7CM1dmoXJKbSP3odVo/8LTSq36w/H6 SKciA0VzfdCQVUADoNG+IjaAQ4VHdkPBbJuWcizDe1AEgYyrOSX0dci8Rt58QTdpf20um 2916f3bmqMCzGFF8r01J5R0oxTxVvckDC+jeJLwOk5CGTs2VQpgvQV8JLoYUNNPzaoMwf 7jGI/inl1Nl83JEeJ8aFlGyGcaUTXUVSxgU39p24Gz9LSxQIX4iMonHTvDC7p3euqNQ2l SE0sMcZfR+7kO/nQEzPGRVMMCEHJGCuVY6gdgcZrlpndKA6cil+4Yjw1KBPF/VjKg8Q== 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=UTSnF1ej; 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 30C04606A320; Wed, 18 Nov 2026 15:26:41 +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=UTSnF1ej Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88DD21F000C4; Wed, 18 Nov 2026 15:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795015601; bh=v5ZfLTX+QiY0avi18ZpwEB5Txc9lts2ZKubmfTDMZok=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UTSnF1ejD+WCMbahEXbmx9C2h03qAT/9xozNCXA/JQ6PxciZRsFbDvsHjcrNx/Fer iAh43Ko578XdFGs3jYblLD4cc5tRAIOXkWKoK09iShcazLztlpsR1seQlMjlcAx1wI FZAvmOrvXW/U4Rn1emQuHZAbuWK6meKtxA82/RkM= 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 7.3 0231/2651] efi/cper: Reject CPER records with an out-of-range error_data_length Date: Wed, 18 Nov 2026 15:24:31 +0100 Message-ID: <20261118150256.177298465@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150247.972732815@linuxfoundation.org> References: <20261118150247.972732815@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-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 06b4fdb59917a..332c78f2d5617 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -752,7 +752,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); @@ -762,10 +762,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