lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0heV36XbRy8TynZuB_sLTKHQDPTiuG_KxX=yYoF4oU0Yg@mail.gmail.com>
Date: Fri, 26 Apr 2024 19:25:17 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Rithvik Rama <rithvik.rama@...il.com>
Cc: rafael@...nel.org, lenb@...nel.org, linux-acpi@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Tony Luck <tony.luck@...el.com>, 
	Borislav Petkov <bp@...en8.de>
Subject: Re: [PATCH] ACPI/ADXL: Added function for ADXL DSM Function 3

On Sun, Mar 31, 2024 at 7:11 AM Rithvik Rama <rithvik.rama@...il.com> wrote:
>
> Current driver supports only Function Index 1 & 2 as mentioned in the
> ACPI ADXL DSM Interface. Added a function for ACPI Function Index 3.

What's happened that it has become useful now?

Who's going to use it and for what purpose?

> Signed-off-by: Rithvik Rama <rithvik.rama@...il.com>
> ---
>  drivers/acpi/acpi_adxl.c | 54 +++++++++++++++++++++++++++++++++++++++-
>  include/linux/adxl.h     |  1 +
>  2 files changed, 54 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/acpi_adxl.c b/drivers/acpi/acpi_adxl.c
> index 13c8f7b50c46..5bf53662b737 100644
> --- a/drivers/acpi/acpi_adxl.c
> +++ b/drivers/acpi/acpi_adxl.c
> @@ -14,6 +14,7 @@
>  #define ADXL_REVISION                  0x1
>  #define ADXL_IDX_GET_ADDR_PARAMS       0x1
>  #define ADXL_IDX_FORWARD_TRANSLATE     0x2
> +#define ADXL_IDX_REVERSE_TRANSLATE     0X3
>  #define ACPI_ADXL_PATH                 "\\_SB.ADXL"
>
>  /*
> @@ -135,6 +136,56 @@ int adxl_decode(u64 addr, u64 component_values[])
>  }
>  EXPORT_SYMBOL_GPL(adxl_decode);
>
> +/**
> + * adxl_reverse_decode - Ask BIOS to decode a memory address to system address
> + * @component_values: pointer to array of values for each component
> + * Returns 0 on success, negative error code otherwise
> + *

Redundant line.

> + */
> +
> +int adxl_reverse_decode(u64 component_values[])
> +{
> +       union acpi_object *argv4, *results, *r;
> +       int i, cnt;
> +
> +       argv4 = kzalloc((adxl_count+1)*sizeof(*argv4), GFP_KERNEL);

kcalloc()?

> +       if (!argv4)
> +               return -ENOMEM;
> +
> +       if (!adxl_component_names)
> +               return -EOPNOTSUPP;

This could be checked before allocating memory which is now leaked if
it is NULL.

This function generally leaks the argv4 memory AFAICS.

> +
> +       argv4[0].type = ACPI_TYPE_PACKAGE;
> +       argv4[0].package.count = adxl_count;
> +       argv4[0].package.elements = &argv4[1];
> +
> +       /*
> +        * Loop through supported memory component values
> +        */
> +       for (i = 1; i <= adxl_count; i++) {
> +               argv4[i].integer.type = ACPI_TYPE_INTEGER;
> +               argv4[i].integer.value = component_values[i-1];
> +       }
> +
> +       results = adxl_dsm(ADXL_IDX_REVERSE_TRANSLATE, argv4);
> +       if (!results)
> +               return -EINVAL;
> +
> +       r = results->package.elements + 1;
> +       cnt = r->package.count;
> +       if (cnt != adxl_count) {
> +               ACPI_FREE(results);
> +               return -EINVAL;
> +       }
> +       r = r->package.elements;
> +       for (i = 0; i < cnt; i++)
> +               component_values[i] = r[i].integer.value;
> +
> +       ACPI_FREE(results);
> +       return 0;
> +}
> +EXPORT_SYMBOL_GPL(adxl_reverse_decode);

No users of this are being added.

For this to be applicable, you need to also submit a patch adding a
caller of adxl_reverse_decode().

> +
>  static int __init adxl_init(void)
>  {
>         char *path = ACPI_ADXL_PATH;
> @@ -155,7 +206,8 @@ static int __init adxl_init(void)
>
>         if (!acpi_check_dsm(handle, &adxl_guid, ADXL_REVISION,
>                             ADXL_IDX_GET_ADDR_PARAMS |
> -                           ADXL_IDX_FORWARD_TRANSLATE)) {
> +                           ADXL_IDX_FORWARD_TRANSLATE |
> +                           ADXL_IDX_REVERSE_TRANSLATE)) {
>                 pr_info("DSM method does not support forward translate\n");
>                 return -ENODEV;
>         }
> diff --git a/include/linux/adxl.h b/include/linux/adxl.h
> index 2a629acb4c3f..f3fea64a270c 100644
> --- a/include/linux/adxl.h
> +++ b/include/linux/adxl.h
> @@ -9,5 +9,6 @@
>
>  const char * const *adxl_get_component_names(void);
>  int adxl_decode(u64 addr, u64 component_values[]);
> +int adxl_reverse_decode(u64 component_values[]);
>
>  #endif /* _LINUX_ADXL_H */
> --

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ