From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Ard Biesheuvel <ardb@kernel.org>, Borislav Petkov <bp@alien8.de>,
Breno Leitao <leitao@debian.org>,
Dave Jiang <dave.jiang@intel.com>, Fan Ni <fan.ni@samsung.com>,
Hanjun Guo <guohanjun@huawei.com>,
Huang Yiwei <quic_hyiwei@quicinc.com>,
Ira Weiny <ira.weiny@intel.com>,
Jason Tian <jason@os.amperecomputing.com>,
Len Brown <lenb@kernel.org>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Shuai Xue <xueshuai@linux.alibaba.com>,
"Smita Koralahalli" <Smita.KoralahalliChannabasappa@amd.com>,
Tony Luck <tony.luck@intel.com>, <linux-acpi@vger.kernel.org>,
<linux-efi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] apei/ghes: don't go past the ARM processor CPER record buffer
Date: Mon, 8 Dec 2025 15:55:22 +0000 [thread overview]
Message-ID: <20251208155522.0000162e@huawei.com> (raw)
In-Reply-To: <0f03f383fa76e41747b95713d50350be21867ccb.1764326826.git.mchehab+huawei@kernel.org>
On Fri, 28 Nov 2025 11:53:00 +0100
Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:
> There's a logic inside ghes/cper to detect if the section_length
> is too small, but it doesn't detect if it is too big.
>
> Currently, if the firmware receives an ARM processor CPER record
> stating that a section length is big, kernel will blindly trust
> section_lentgh, producing a very long dump. For instance, a 67
section_length
> bytes record with ERR_INFO_NUM set 46198 and section length
> set to 854918320 would dump a lot of data going a way past the
> firmware memory-mapped area.
>
> Fix it by adding a logic to prevent it to go past the buffer
> if ERR_INFO_NUM is too big, making it report instead:
>
> [Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1
> [Hardware Error]: event severity: recoverable
> [Hardware Error]: Error 0, type: recoverable
> [Hardware Error]: section_type: ARM processor error
> [Hardware Error]: MIDR: 0xff304b2f8476870a
> [Hardware Error]: section length: 854918320, CPER size: 67
> [Hardware Error]: section length is too big
> [Hardware Error]: firmware-generated error record is incorrect
> [Hardware Error]: ERR_INFO_NUM is 46198
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
> drivers/acpi/apei/ghes.c | 13 +++++++++++++
> drivers/firmware/efi/cper-arm.c | 14 +++++++++-----
> drivers/firmware/efi/cper.c | 3 ++-
> include/linux/cper.h | 3 ++-
> 4 files changed, 26 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
> index 56107aa00274..8b90b6f3e866 100644
> --- a/drivers/acpi/apei/ghes.c
> +++ b/drivers/acpi/apei/ghes.c
> @@ -557,6 +557,7 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
> {
> struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata);
> int flags = sync ? MF_ACTION_REQUIRED : 0;
> + int length = gdata->error_data_length;
> char error_type[120];
> bool queued = false;
> int sec_sev, i;
> @@ -568,7 +569,12 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
> return false;
>
> p = (char *)(err + 1);
> + length -= sizeof(err);
> +
> for (i = 0; i < err->err_info_num; i++) {
> + if (length <= 0)
> + break;
> +
> struct cper_arm_err_info *err_info = (struct cper_arm_err_info *)p;
> bool is_cache = err_info->type & CPER_ARM_CACHE_ERROR;
> bool has_pa = (err_info->validation_bits & CPER_ARM_INFO_VALID_PHYSICAL_ADDR);
> @@ -580,10 +586,17 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
> * and don't filter out 'corrected' error here.
> */
> if (is_cache && has_pa) {
> + length -= err_info->length;
> + if (length < 0)
> + break;
> queued = ghes_do_memory_failure(err_info->physical_fault_addr, flags);
> p += err_info->length;
> +
> continue;
> }
> + length -= err_info->length;
> + if (length < 0)
Indent odd.
> + break;
>
> cper_bits_to_str(error_type, sizeof(error_type),
> FIELD_GET(CPER_ARM_ERR_TYPE_MASK, err_info->type),
next parent reply other threads:[~2025-12-08 15:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1764326826.git.mchehab+huawei@kernel.org>
[not found] ` <0f03f383fa76e41747b95713d50350be21867ccb.1764326826.git.mchehab+huawei@kernel.org>
2025-12-08 15:55 ` Jonathan Cameron [this message]
2025-12-09 2:42 ` [PATCH v2 1/2] apei/ghes: don't go past the ARM processor CPER record buffer Shuai Xue
[not found] <cover.1764169337.git.mchehab+huawei@kernel.org>
2025-11-26 15:05 ` Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251208155522.0000162e@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=Smita.KoralahalliChannabasappa@amd.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=dave.jiang@intel.com \
--cc=fan.ni@samsung.com \
--cc=guohanjun@huawei.com \
--cc=ira.weiny@intel.com \
--cc=jason@os.amperecomputing.com \
--cc=leitao@debian.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=mchehab@kernel.org \
--cc=peterz@infradead.org \
--cc=quic_hyiwei@quicinc.com \
--cc=rafael@kernel.org \
--cc=tony.luck@intel.com \
--cc=xueshuai@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.