public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPICA: Fix dereference in acpi_ev_address_space_dispatch()
@ 2024-10-31 17:31 George Rurikov
  2024-10-31 19:51 ` Fedor Pchelkin
  2024-11-05 17:11 ` Sudeep Holla
  0 siblings, 2 replies; 3+ messages in thread
From: George Rurikov @ 2024-10-31 17:31 UTC (permalink / raw)
  To: Robert Moore
  Cc: George Rurikov, Rafael J. Wysocki, Sudeep Holla, linux-acpi,
	acpica-devel, linux-kernel, lvc-project, stable

When support for  PCC Opregion was added, validation of field_obj
was missed.
Based on the acpi_ev_address_space_dispatch function description,
field_obj can be NULL, and also when acpi_ev_address_space_dispatch
is called in the acpi_ex_region_read() NULL is passed as field_obj.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 0acf24ad7e10 ("ACPICA: Add support for PCC Opregion special context data")
Cc: stable@vger.kernel.org
Signed-off-by: George Rurikov <grurikov@gmail.com>
---
 drivers/acpi/acpica/evregion.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index cf53b9535f18..03e8b6f186af 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -164,13 +164,17 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
 		}
 
 		if (region_obj->region.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) {
-			struct acpi_pcc_info *ctx =
-			    handler_desc->address_space.context;
-
-			ctx->internal_buffer =
-			    field_obj->field.internal_pcc_buffer;
-			ctx->length = (u16)region_obj->region.length;
-			ctx->subspace_id = (u8)region_obj->region.address;
+			if (field_obj != NULL) {
+				struct acpi_pcc_info *ctx =
+					handler_desc->address_space.context;
+
+				ctx->internal_buffer =
+					field_obj->field.internal_pcc_buffer;
+				ctx->length = (u16)region_obj->region.length;
+				ctx->subspace_id = (u8)region_obj->region.address;
+			} else {
+				return_ACPI_STATUS(AE_ERROR);
+			}
 		}
 
 		if (region_obj->region.space_id ==
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ACPICA: Fix dereference in acpi_ev_address_space_dispatch()
  2024-10-31 17:31 [PATCH] ACPICA: Fix dereference in acpi_ev_address_space_dispatch() George Rurikov
@ 2024-10-31 19:51 ` Fedor Pchelkin
  2024-11-05 17:11 ` Sudeep Holla
  1 sibling, 0 replies; 3+ messages in thread
From: Fedor Pchelkin @ 2024-10-31 19:51 UTC (permalink / raw)
  To: George Rurikov
  Cc: Robert Moore, lvc-project, acpica-devel, linux-kernel, stable,
	linux-acpi, Sudeep Holla, Rafael J. Wysocki

On Thu, 31. Oct 20:31, George Rurikov wrote:
> When support for  PCC Opregion was added, validation of field_obj
> was missed.
> Based on the acpi_ev_address_space_dispatch function description,
> field_obj can be NULL, and also when acpi_ev_address_space_dispatch
> is called in the acpi_ex_region_read() NULL is passed as field_obj.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 0acf24ad7e10 ("ACPICA: Add support for PCC Opregion special context data")
> Cc: stable@vger.kernel.org
> Signed-off-by: George Rurikov <grurikov@gmail.com>
> ---
>  drivers/acpi/acpica/evregion.c | 18 +++++++++++-------

Hi George,

ACPICA patches go first via a separate Github project [1].
[1]: https://github.com/acpica/acpica

Please see [2] and [3] for more info:
[2]: https://lore.kernel.org/acpica-devel/CAJZ5v0i7LYzF13M0qdeYWXZ7uO6HUpAS7pE5RJnOAJtKB8o88A@mail.gmail.com/
[3]: https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html

>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
> index cf53b9535f18..03e8b6f186af 100644
> --- a/drivers/acpi/acpica/evregion.c
> +++ b/drivers/acpi/acpica/evregion.c
> @@ -164,13 +164,17 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
>  		}
>  
>  		if (region_obj->region.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) {
> -			struct acpi_pcc_info *ctx =
> -			    handler_desc->address_space.context;
> -
> -			ctx->internal_buffer =
> -			    field_obj->field.internal_pcc_buffer;
> -			ctx->length = (u16)region_obj->region.length;
> -			ctx->subspace_id = (u8)region_obj->region.address;
> +			if (field_obj != NULL) {
> +				struct acpi_pcc_info *ctx =
> +					handler_desc->address_space.context;
> +
> +				ctx->internal_buffer =
> +					field_obj->field.internal_pcc_buffer;
> +				ctx->length = (u16)region_obj->region.length;
> +				ctx->subspace_id = (u8)region_obj->region.address;
> +			} else {
> +				return_ACPI_STATUS(AE_ERROR);
> +			}
>  		}
>  
>  		if (region_obj->region.space_id ==
> -- 
> 2.34.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ACPICA: Fix dereference in acpi_ev_address_space_dispatch()
  2024-10-31 17:31 [PATCH] ACPICA: Fix dereference in acpi_ev_address_space_dispatch() George Rurikov
  2024-10-31 19:51 ` Fedor Pchelkin
@ 2024-11-05 17:11 ` Sudeep Holla
  1 sibling, 0 replies; 3+ messages in thread
From: Sudeep Holla @ 2024-11-05 17:11 UTC (permalink / raw)
  To: George Rurikov
  Cc: Robert Moore, Sudeep Holla, Rafael J. Wysocki,
	linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
	stable@vger.kernel.org

On Thu, Oct 31, 2024 at 05:31:46PM +0000, George Rurikov wrote:
> * # Be careful, this email looks suspicious; * WARNING!  This email has multiple suspicious indicators that suggest it is malicious, please handle links and attachments with extreme care. *
> When support for  PCC Opregion was added, validation of field_obj
> was missed.
> Based on the acpi_ev_address_space_dispatch function description,
> field_obj can be NULL, and also when acpi_ev_address_space_dispatch
> is called in the acpi_ex_region_read() NULL is passed as field_obj.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>

LGTM, please submit this to ACPICA project as specified in the documentation
if not already done. Otherwise a reference to the merge request there would
be good here.

--
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-05 17:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-31 17:31 [PATCH] ACPICA: Fix dereference in acpi_ev_address_space_dispatch() George Rurikov
2024-10-31 19:51 ` Fedor Pchelkin
2024-11-05 17:11 ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox