linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] acpi/processor_idle.c: Fix kernel pointer leak
@ 2021-09-29 10:46 Guo Zhi
  2021-09-29 12:07 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Guo Zhi @ 2021-09-29 10:46 UTC (permalink / raw)
  To: rafael, lenb; +Cc: linux-acpi, linux-kernel, Guo Zhi

Pointers should be printed with %p or %px rather than
cast to 'long' and pinted with %ld.
Change %ld to %p to print the secured pointer.

Signed-off-by: Guo Zhi <qtxuning1999@sjtu.edu.cn>
---
 drivers/acpi/processor_idle.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index f37fba9e5ba0..a9f4ab072583 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -73,9 +73,9 @@ static int set_max_cstate(const struct dmi_system_id *id)
 	if (max_cstate > ACPI_PROCESSOR_MAX_POWER)
 		return 0;
 
-	pr_notice("%s detected - limiting to C%ld max_cstate."
+	pr_notice("%s detected - limiting to C%p max_cstate."
 		  " Override with \"processor.max_cstate=%d\"\n", id->ident,
-		  (long)id->driver_data, ACPI_PROCESSOR_MAX_POWER + 1);
+		id->driver_data, ACPI_PROCESSOR_MAX_POWER + 1);
 
 	max_cstate = (long)id->driver_data;
 
-- 
2.33.0


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

* Re: [PATCH] acpi/processor_idle.c: Fix kernel pointer leak
  2021-09-29 10:46 [PATCH] acpi/processor_idle.c: Fix kernel pointer leak Guo Zhi
@ 2021-09-29 12:07 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2021-09-29 12:07 UTC (permalink / raw)
  To: Guo Zhi
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Wed, Sep 29, 2021 at 12:56 PM Guo Zhi <qtxuning1999@sjtu.edu.cn> wrote:
>
> Pointers should be printed with %p or %px rather than
> cast to 'long' and pinted with %ld.
> Change %ld to %p to print the secured pointer.

In this particular case, id->driver_data represents a proper integer,
not an address, although technically it is a pointer data type.  It
shouldn't be printed with %p and the patch is incorrect.

>
> Signed-off-by: Guo Zhi <qtxuning1999@sjtu.edu.cn>
> ---
>  drivers/acpi/processor_idle.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
> index f37fba9e5ba0..a9f4ab072583 100644
> --- a/drivers/acpi/processor_idle.c
> +++ b/drivers/acpi/processor_idle.c
> @@ -73,9 +73,9 @@ static int set_max_cstate(const struct dmi_system_id *id)
>         if (max_cstate > ACPI_PROCESSOR_MAX_POWER)
>                 return 0;
>
> -       pr_notice("%s detected - limiting to C%ld max_cstate."
> +       pr_notice("%s detected - limiting to C%p max_cstate."
>                   " Override with \"processor.max_cstate=%d\"\n", id->ident,
> -                 (long)id->driver_data, ACPI_PROCESSOR_MAX_POWER + 1);
> +               id->driver_data, ACPI_PROCESSOR_MAX_POWER + 1);
>
>         max_cstate = (long)id->driver_data;
>
> --
> 2.33.0
>

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

end of thread, other threads:[~2021-09-29 12:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29 10:46 [PATCH] acpi/processor_idle.c: Fix kernel pointer leak Guo Zhi
2021-09-29 12:07 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).