From nobody Sat Feb 7 15:10:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 97C8E36C5B0; Wed, 7 Jan 2026 16:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767804130; cv=none; b=TdcbiDdluzQoFfbbfUkgqHrGLzL7p+2kcCuuzWeX5PYTydKuyQrr0tmjnZMzdUtYbzjo1CLY03l0k6Af1Xw+/1SPSCOMFKm79m2cermTlRZM6WFd7AmvWil60xqRR/xPxlXdP8F7VjxsLRVcy77I8VywYVzGYjY7Cpl/8COE6Vg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767804130; c=relaxed/simple; bh=ka2CWUl8OjHLpevWXyf+gxSz2g5ApOySVjvxxdnjmW4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Dc92xlIsniYJmd68moxxDon6rrULrHGqrKXiIeqZQ6z8fgFkdX0yITeWO+AhMqS5RLrd2W/ileN5yAaP3CLHoNrB2V6tnK0ePSbLRiwhp7xomErxl4fDqn6Dj2K5cz5TYkGnVMsFvrGxQFCfIHLLr+azpKHP2dc+62XtYBjmNpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EsFnaruM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EsFnaruM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DD16C19425; Wed, 7 Jan 2026 16:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767804130; bh=ka2CWUl8OjHLpevWXyf+gxSz2g5ApOySVjvxxdnjmW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EsFnaruMgFEGeAFd2+baWXxx9eAcu0C7qP/rtGDhknDNqwmFSaVEWQKB9tk/3dUXj flOyZkVPs0CjjMhoYfMsRszGIN7zsONVk9zOGgJJx/DrUxmvITpWw6eWXvsByOanc4 oPovzjogIOFLw46b6RqpCEkQYvvPtzdarR7YHGr9gUgxF+XdAhrOrvkRtyxXOQcj4N 8B0F+yOBOOLrqePpX/LJK6POQlwlw90g8hyPZxlyY8ISf3LboqnwAs4MwL9Fb5q2oy oRduSdNFKqZMCBiOlrzccZvhTcExD1NokEmwyR0sOIzAEhSvf0KctJhHiA0eAS05HM KgH3MsO9Z/g9g== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vdWbo-00000001bUS-0mDC; Wed, 07 Jan 2026 17:42:08 +0100 From: Mauro Carvalho Chehab To: "Rafael J. Wysocki" Cc: Mauro Carvalho Chehab , acpica-devel@lists.linux.dev, linux-acpi@vger.kernel.org, linux-edac@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Ankit Agrawal , Borislav Petkov , Breno Leitao , Hanjun Guo , Ingo Molnar , Jason Tian , Jonathan Cameron , Len Brown , Mauro Carvalho Chehab , Shuai Xue , Smita Koralahalli , Tony Luck Subject: [PATCH v5 1/4] apei/ghes: ARM processor Error: don't go past allocated memory Date: Wed, 7 Jan 2026 17:41:49 +0100 Message-ID: <7fd9f38413be05ee2d7cfdb0dc31ea2274cf1a54.1767804050.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab If the BIOS generates a very small ARM Processor Error, or an incomplete one, the current logic will fail to deferrence err->section_length and ctx_info->size Add checks to avoid that. With such changes, such GHESv2 records won't cause OOPSes like this: [ 1.492129] Internal error: Oops: 0000000096000005 [#1] SMP [ 1.495449] Modules linked in: [ 1.495820] CPU: 0 UID: 0 PID: 9 Comm: kworker/0:0 Not tainted 6.18.0-rc= 1-00017-gabadcc3553dd-dirty #18 PREEMPT [ 1.496125] Hardware name: QEMU QEMU Virtual Machine, BIOS unknown 02/02= /2022 [ 1.496433] Workqueue: kacpi_notify acpi_os_execute_deferred [ 1.496967] pstate: 814000c5 (Nzcv daIF +PAN -UAO -TCO +DIT -SSBS BTYPE= =3D--) [ 1.497199] pc : log_arm_hw_error+0x5c/0x200 [ 1.497380] lr : ghes_handle_arm_hw_error+0x94/0x220 0xffff8000811c5324 is in log_arm_hw_error (../drivers/ras/ras.c:75). 70 err_info =3D (struct cper_arm_err_info *)(err + 1); 71 ctx_info =3D (struct cper_arm_ctx_info *)(err_info + err->err_info_num); 72 ctx_err =3D (u8 *)ctx_info; 73 74 for (n =3D 0; n < err->context_info_num; n++) { 75 sz =3D sizeof(struct cper_arm_ctx_info) + ctx_info->size; 76 ctx_info =3D (struct cper_arm_ctx_info *)((long)ctx_info + sz); 77 ctx_len +=3D sz; 78 } 79 and similar ones while trying to access section_length on an error dump with too small size. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- drivers/acpi/apei/ghes.c | 32 ++++++++++++++++++++++++++++---- drivers/ras/ras.c | 6 +++++- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 0dc767392a6c..fc3f8aed99d5 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -552,21 +552,45 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest= _generic_data *gdata, { struct cper_sec_proc_arm *err =3D acpi_hest_get_payload(gdata); int flags =3D sync ? MF_ACTION_REQUIRED : 0; + int length =3D gdata->error_data_length; char error_type[120]; bool queued =3D false; int sec_sev, i; char *p; =20 sec_sev =3D ghes_severity(gdata->error_severity); - log_arm_hw_error(err, sec_sev); + if (length >=3D sizeof(*err)) { + log_arm_hw_error(err, sec_sev); + } else { + pr_warn(FW_BUG "arm error length: %d\n", length); + pr_warn(FW_BUG "length is too small\n"); + pr_warn(FW_BUG "firmware-generated error record is incorrect\n"); + return false; + } + if (sev !=3D GHES_SEV_RECOVERABLE || sec_sev !=3D GHES_SEV_RECOVERABLE) return false; =20 p =3D (char *)(err + 1); + length -=3D sizeof(err); + for (i =3D 0; i < err->err_info_num; i++) { - struct cper_arm_err_info *err_info =3D (struct cper_arm_err_info *)p; - bool is_cache =3D err_info->type & CPER_ARM_CACHE_ERROR; - bool has_pa =3D (err_info->validation_bits & CPER_ARM_INFO_VALID_PHYSICA= L_ADDR); + struct cper_arm_err_info *err_info; + bool is_cache, has_pa; + + /* Ensure we have enough data for the error info header */ + if (length < sizeof(*err_info)) + break; + + err_info =3D (struct cper_arm_err_info *)p; + + /* Validate the claimed length before using it */ + length -=3D err_info->length; + if (length < 0) + break; + + is_cache =3D err_info->type & CPER_ARM_CACHE_ERROR; + has_pa =3D (err_info->validation_bits & CPER_ARM_INFO_VALID_PHYSICAL_ADD= R); =20 /* * The field (err_info->error_info & BIT(26)) is fixed to set to diff --git a/drivers/ras/ras.c b/drivers/ras/ras.c index 2a5b5a9fdcb3..03df3db62334 100644 --- a/drivers/ras/ras.c +++ b/drivers/ras/ras.c @@ -72,7 +72,11 @@ void log_arm_hw_error(struct cper_sec_proc_arm *err, con= st u8 sev) ctx_err =3D (u8 *)ctx_info; =20 for (n =3D 0; n < err->context_info_num; n++) { - sz =3D sizeof(struct cper_arm_ctx_info) + ctx_info->size; + sz =3D sizeof(struct cper_arm_ctx_info); + + if (sz + (long)ctx_info - (long)err >=3D err->section_length) + sz +=3D ctx_info->size; + ctx_info =3D (struct cper_arm_ctx_info *)((long)ctx_info + sz); ctx_len +=3D sz; } --=20 2.52.0 From nobody Sat Feb 7 15:10:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 05AC83775C5; Wed, 7 Jan 2026 16:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767804131; cv=none; b=jbq4qtnga8e5eoYnrKhAp50u9b6h4qApmstdA3Zp5N9lrkGNMamWmFh0Od0nNToXhgg5Yp6s3jEAAtLfj0fjqDZAR/pzW9NBZZjCStgLeF/0oQdubePcQw4Nf7wwcDyRykdgZQ0HPVh5xPBsEma2h4no7isSt7mRegWLb9QwwUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767804131; c=relaxed/simple; bh=3Avwk9ah4fvsu5pW2Hk/IxHeMU3rEwQMuWdy8ZlvDv0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FsLL74LP2fSw6ebzTZvPqD09I64NYUqlZt6YMZfmhmgy17N/58PBeP/QwxJU4rfvpQtj02usCVGMPmoi8pF1NR2yHvwn0EBtwOsNxnZ6j4xULg3CQa8CpETWXuXvKo3Gpe65Thqz5fskBPZ8Y/1YzG/kIl+/lH35xuexiHokdpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IGlCjgnk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IGlCjgnk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B6B8C19424; Wed, 7 Jan 2026 16:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767804130; bh=3Avwk9ah4fvsu5pW2Hk/IxHeMU3rEwQMuWdy8ZlvDv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IGlCjgnkUlSettDBESFYBaNmqrNjBAaZYHMqVTdHXB9TOnuylmrnim8gt2DlzuACq cLNRb3k+ZgJb3uiBYy5bcicEfumLsuLBHI+GadZ0E4Umv2yIqIDdZleOQ+OzbxSJbd SC2uJQUeusKeYxUvuoaarBML0vdwmvMCc/vh67YcjP7MDbKSXeXSlDwMh8sRE6DI/c Zwv0yP6kht2fmf776mM1KH+ydl7KwBs5cqV6eWEyys2Uc1Y63546C3Q7X0jpgGYb0B eCsGe00jvgPOEbsOvcZhPaLXzT2AJy3MadwZNQBGGSvdi1MOLVZoW6ReDTFV0fgoUM KqCZmryORP67A== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vdWbo-00000001bUW-0tY9; Wed, 07 Jan 2026 17:42:08 +0100 From: Mauro Carvalho Chehab To: "Rafael J. Wysocki" , Ard Biesheuvel Cc: Mauro Carvalho Chehab , acpica-devel@lists.linux.dev, linux-acpi@vger.kernel.org, linux-edac@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Dave Jiang , Ira Weiny , Jonathan Cameron , Smita Koralahalli Subject: [PATCH v5 2/4] efi/cper: don't go past the ARM processor CPER record buffer Date: Wed, 7 Jan 2026 17:41:50 +0100 Message-ID: <41cd9f6b3ace3cdff7a5e864890849e4b1c58b63.1767804050.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab 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_length, producing a very long dump. For instance, a 67 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 Reviewed-by: Jonathan Cameron --- drivers/firmware/efi/cper-arm.c | 12 ++++++++---- drivers/firmware/efi/cper.c | 3 ++- include/linux/cper.h | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/efi/cper-arm.c b/drivers/firmware/efi/cper-ar= m.c index 76542a53e202..b21cb1232d82 100644 --- a/drivers/firmware/efi/cper-arm.c +++ b/drivers/firmware/efi/cper-arm.c @@ -226,7 +226,8 @@ static void cper_print_arm_err_info(const char *pfx, u3= 2 type, } =20 void cper_print_proc_arm(const char *pfx, - const struct cper_sec_proc_arm *proc) + const struct cper_sec_proc_arm *proc, + u32 length) { int i, len, max_ctx_type; struct cper_arm_err_info *err_info; @@ -238,9 +239,12 @@ void cper_print_proc_arm(const char *pfx, =20 len =3D proc->section_length - (sizeof(*proc) + proc->err_info_num * (sizeof(*err_info))); - if (len < 0) { - printk("%ssection length: %d\n", pfx, proc->section_length); - printk("%ssection length is too small\n", pfx); + + if (len < 0 || proc->section_length > length) { + printk("%ssection length: %d, CPER size: %d\n", + pfx, proc->section_length, length); + printk("%ssection length is too %s\n", pfx, + (len < 0) ? "small" : "big"); printk("%sfirmware-generated error record is incorrect\n", pfx); printk("%sERR_INFO_NUM is %d\n", pfx, proc->err_info_num); return; diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index 0232bd040f61..88fc0293f876 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -659,7 +659,8 @@ cper_estatus_print_section(const char *pfx, struct acpi= _hest_generic_data *gdata =20 printk("%ssection_type: ARM processor error\n", newpfx); if (gdata->error_data_length >=3D sizeof(*arm_err)) - cper_print_proc_arm(newpfx, arm_err); + cper_print_proc_arm(newpfx, arm_err, + gdata->error_data_length); else goto err_section_too_small; #endif diff --git a/include/linux/cper.h b/include/linux/cper.h index 5b1236d8c65b..440b35e459e5 100644 --- a/include/linux/cper.h +++ b/include/linux/cper.h @@ -595,7 +595,8 @@ void cper_mem_err_pack(const struct cper_sec_mem_err *, const char *cper_mem_err_unpack(struct trace_seq *, struct cper_mem_err_compact *); void cper_print_proc_arm(const char *pfx, - const struct cper_sec_proc_arm *proc); + const struct cper_sec_proc_arm *proc, + u32 length); void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc); int cper_mem_err_location(struct cper_mem_err_compact *mem, char *msg); --=20 2.52.0 From nobody Sat Feb 7 15:10:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A4366375147; Wed, 7 Jan 2026 16:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767804130; cv=none; b=KYXIdTZV8vPqOh2zgCzlQ2+lMrPflE+MLDD/yMySHkkP+BjCUiG/D1iCx/69Rj/xK54WxzmIRUeds5yQTCGihMS2UTxAxrrT7DF4OMm/WWp9qpTAA2+g+gG93RSV5gxrz4idhRIxvKhxj1En6QqnFjzezDyk1rtY9JVLWX+GqTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767804130; c=relaxed/simple; bh=/2sTI+ZMqBflhdzNpuA/tHH+ApzFoxDz3AuVKHALOJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=geA45OU6N9qHt0Df5XAe0coNFpk1oHA0+TTYJc78luo6PVxzIbDScwiOcEbmN3hVofS/lZaVoArxlX3Gz4hPBc7g5DlpoZXbcmIUHX61VtbE5jZa+KLy3+C0ogry89CkfRFWGZcQhdkj6jtTliY91cUQG5RGXs4fHGhtofT7040= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=do6/dmF2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="do6/dmF2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19164C4CEF7; Wed, 7 Jan 2026 16:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767804130; bh=/2sTI+ZMqBflhdzNpuA/tHH+ApzFoxDz3AuVKHALOJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=do6/dmF2v9JUCIn30eVeQuTQBuGtPtuXYPohyxNpMWulIKhHXoxNcSK/R0KdNcVi8 9qYCyWMCmhGXSjvaUNBHYit5VRN7u7ZfKhA6bGumSfU2fWXJgwUx1H1H0xkCXk36Ks izH/Ax7rjqNUPWHAbLdnkdYeMh33++M5HNxVdiCCoUMGprMCvZX7tGb3OQ/2/NOSq+ G7/v2auJjKQol6N+ytlzh/NZyH9IJ2Egq/TTYOptsX2ullRJThHV+F7Q0vygvYiNUa Mz9KKxAJ1K40cW9hLnS0kY9K7f67y1xlWD9lZw6xjeqd+9s9Xw6HsAGhHN+mjw7Iv3 wCIsBzW3P6YQg== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vdWbo-00000001bUa-11CE; Wed, 07 Jan 2026 17:42:08 +0100 From: Mauro Carvalho Chehab To: "Rafael J. Wysocki" Cc: Mauro Carvalho Chehab , acpica-devel@lists.linux.dev, linux-acpi@vger.kernel.org, linux-edac@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Ankit Agrawal , Borislav Petkov , Breno Leitao , Hanjun Guo , Huang Yiwei , Jason Tian , Jonathan Cameron , Len Brown , Mauro Carvalho Chehab , Robert Moore , Shuai Xue , Smita Koralahalli , Tony Luck Subject: [PATCH v5 3/4] apei/ghes: ensure that won't go past CPER allocated record Date: Wed, 7 Jan 2026 17:41:51 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab The logic at ghes_new() prevents allocating too large records, by checking if they're bigger than GHES_ESTATUS_MAX_SIZE (currently, 64KB). Yet, the allocation is done with the actual number of pages from the CPER bios table location, which can be smaller. Yet, a bad firmware could send data with a different size, which might be bigger than the allocated memory, causing an OOPS: [13095.899926] Unable to handle kernel paging request at virtual address ff= f00000f9b40000 [13095.899961] Mem abort info: [13095.900017] ESR =3D 0x0000000096000007 [13095.900088] EC =3D 0x25: DABT (current EL), IL =3D 32 bits [13095.900156] SET =3D 0, FnV =3D 0 [13095.900181] EA =3D 0, S1PTW =3D 0 [13095.900211] FSC =3D 0x07: level 3 translation fault [13095.900255] Data abort info: [13095.900421] ISV =3D 0, ISS =3D 0x00000007, ISS2 =3D 0x00000000 [13095.900486] CM =3D 0, WnR =3D 0, TnD =3D 0, TagAccess =3D 0 [13095.900525] GCS =3D 0, Overlay =3D 0, DirtyBit =3D 0, Xs =3D 0 [13095.900713] swapper pgtable: 4k pages, 52-bit VAs, pgdp=3D000000008ba160= 00 [13095.900752] [fff00000f9b40000] pgd=3D180000013ffff403, p4d=3D180000013ff= fe403, pud=3D180000013f85b403, pmd=3D180000013f68d403, pte=3D00000000000000= 00 [13095.901312] Internal error: Oops: 0000000096000007 [#1] SMP [13095.901659] Modules linked in: [13095.902201] CPU: 0 UID: 0 PID: 303 Comm: kworker/0:1 Not tainted 6.19.0-= rc1-00002-gda407d200220 #34 PREEMPT [13095.902461] Hardware name: QEMU QEMU Virtual Machine, BIOS unknown 02/02= /2022 [13095.902719] Workqueue: kacpi_notify acpi_os_execute_deferred [13095.903778] pstate: 214020c5 (nzCv daIF +PAN -UAO -TCO +DIT -SSBS BTYPE= =3D--) [13095.903892] pc : hex_dump_to_buffer+0x30c/0x4a0 [13095.904146] lr : hex_dump_to_buffer+0x328/0x4a0 [13095.904204] sp : ffff800080e13880 [13095.904291] x29: ffff800080e13880 x28: ffffac9aba86f6a8 x27: 00000000000= 00083 [13095.904704] x26: fff00000f9b3fffc x25: 0000000000000004 x24: 00000000000= 00004 [13095.905335] x23: ffff800080e13905 x22: 0000000000000010 x21: 00000000000= 00083 [13095.905483] x20: 0000000000000001 x19: 0000000000000008 x18: 00000000000= 00010 [13095.905617] x17: 0000000000000001 x16: 00000007c7f20fec x15: 00000000000= 00020 [13095.905850] x14: 0000000000000008 x13: 0000000000081020 x12: 00000000000= 00008 [13095.906175] x11: ffff800080e13905 x10: ffff800080e13988 x9 : 00000000000= 00000 [13095.906733] x8 : 0000000000000000 x7 : 0000000000000001 x6 : 00000000000= 00020 [13095.907197] x5 : 0000000000000030 x4 : 00000000fffffffe x3 : 00000000000= 00000 [13095.907623] x2 : ffffac9aba78c1c8 x1 : ffffac9aba76d0a8 x0 : 00000000000= 00008 [13095.908284] Call trace: [13095.908866] hex_dump_to_buffer+0x30c/0x4a0 (P) [13095.909135] print_hex_dump+0xac/0x170 [13095.909179] cper_estatus_print_section+0x90c/0x968 [13095.909336] cper_estatus_print+0xf0/0x158 [13095.909348] __ghes_print_estatus+0xa0/0x148 [13095.909656] ghes_proc+0x1bc/0x220 [13095.909883] ghes_notify_hed+0x5c/0xb8 [13095.909957] notifier_call_chain+0x78/0x148 [13095.910180] blocking_notifier_call_chain+0x4c/0x80 [13095.910246] acpi_hed_notify+0x28/0x40 [13095.910558] acpi_ev_notify_dispatch+0x50/0x80 [13095.910576] acpi_os_execute_deferred+0x24/0x48 [13095.911161] process_one_work+0x15c/0x3b0 [13095.911326] worker_thread+0x2d0/0x400 [13095.911775] kthread+0x148/0x228 [13095.912082] ret_from_fork+0x10/0x20 [13095.912687] Code: 6b14033f 540001ad a94707e2 f100029f (b8747b44) [13095.914085] ---[ end trace 0000000000000000 ]--- Prevent that by taking the actual allocated are into account when checking for CPER length. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- drivers/acpi/apei/ghes.c | 6 +++++- include/acpi/ghes.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index fc3f8aed99d5..77ea7a5b761f 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -294,6 +295,7 @@ static struct ghes *ghes_new(struct acpi_hest_generic *= generic) error_block_length =3D GHES_ESTATUS_MAX_SIZE; } ghes->estatus =3D kmalloc(error_block_length, GFP_KERNEL); + ghes->estatus_length =3D error_block_length; if (!ghes->estatus) { rc =3D -ENOMEM; goto err_unmap_status_addr; @@ -365,13 +367,15 @@ static int __ghes_check_estatus(struct ghes *ghes, struct acpi_hest_generic_status *estatus) { u32 len =3D cper_estatus_len(estatus); + u32 max_len =3D min(ghes->generic->error_block_length, + ghes->estatus_length); =20 if (len < sizeof(*estatus)) { pr_warn_ratelimited(FW_WARN GHES_PFX "Truncated error status block!\n"); return -EIO; } =20 - if (len > ghes->generic->error_block_length) { + if (!len || len > max_len) { pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid error status block length!= \n"); return -EIO; } diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index ebd21b05fe6e..93db60da5934 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -21,6 +21,7 @@ struct ghes { struct acpi_hest_generic_v2 *generic_v2; }; struct acpi_hest_generic_status *estatus; + unsigned int estatus_length; unsigned long flags; union { struct list_head list; --=20 2.52.0 From nobody Sat Feb 7 15:10:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 05BAC3803F7; Wed, 7 Jan 2026 16:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767804131; cv=none; b=dJB7E7fwy1nuz/xhZkPZEaBZJQgtZXO9/90cC/r447e7adjyFjVMiBpIuYiQuFesWmSJ8DHW7GM6VP85DFvuZSxKdaLUnxBwfS1WM3F/6SsJE1L3MDRafVbyKZ/bHFWME/nENtJBlKjT3gl2JWu+OrNETybiNgvALjfoM+Cu5mA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767804131; c=relaxed/simple; bh=q8mFlp+bD20oQpXP27iO1F9y1ja315WcWvYnI369uAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M3aLXbPrrF/sg2TcZLW098U6FGeMPdzAapIIcDZwtH/Czj0jYIwjdedZcOfY0YqacDWx75XbyNhDBHU0PTK0ort1n1R/GOXEq7nLHrcsYV3GsFg3XERGQW4ymB5aqks9Y9Qc5uipFZ7uF7FT9S7SJPfSyAufLhqgJBpXSI++JOc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F0WZFv8J; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F0WZFv8J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 206AEC19423; Wed, 7 Jan 2026 16:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767804130; bh=q8mFlp+bD20oQpXP27iO1F9y1ja315WcWvYnI369uAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F0WZFv8JcxMq1VizvtDNwWgqxu6kCyb3We/VPemED43l8vYwjOFpbNF8kT1rkX3A3 MpM4g+QDGnejPbr718aRBt8hGEBACJCAhJav0mewrn6/wZe5G2cpL5wvQWSdoI0nhz UWTsWDNTdMiV0LFJKwOJTtyBkjbGKjpWl4+zehvMQbXnd4gV6Lseuh9u9zE7/hEfBk r6D1TZezXQJqROVnddLt+mSYLWRWNA+RfUZQXcwrb+qlGWUAQfW14hsiiv8m28Qe6T /WgpbhBQ9qWpBwvyetrfVlPagtQ3SIcBTsHUUUnNBAHCoAtITn/+xNjyQAxl9eROMM DanBAGI37yPGw== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vdWbo-00000001bUe-184I; Wed, 07 Jan 2026 17:42:08 +0100 From: Mauro Carvalho Chehab To: "Rafael J. Wysocki" , Ard Biesheuvel Cc: Mauro Carvalho Chehab , acpica-devel@lists.linux.dev, linux-acpi@vger.kernel.org, linux-edac@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/4] efi/cper: don't dump the entire memory region Date: Wed, 7 Jan 2026 17:41:52 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab The current logic at cper_print_fw_err() doesn't check if the error record length is big enough to handle offset. On a bad firmware, if the ofset is above the actual record, length -=3D offset will underflow, making it dump the entire memory. The end result can be: - the logic taking a lot of time dumping large regions of memory; - data disclosure due to the memory dumps; - an OOPS, if it tries to dump an unmapped memory region. Fix it by checking if the section length is too small before doing a hex dump. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- drivers/firmware/efi/cper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index 88fc0293f876..0e938fc5ccb1 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -560,6 +560,11 @@ static void cper_print_fw_err(const char *pfx, } else { offset =3D sizeof(*fw_err); } + if (offset > length) { + printk("%s""error section length is too small: offset=3D%d, length=3D%d\= n", + pfx, offset, length); + return; + } =20 buf +=3D offset; length -=3D offset; --=20 2.52.0