All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 09/19] tools/power turbostat: fix buffer overrun
  2019-08-31 19:34 [PATCH 01/19] tools/power x86_energy_perf_policy: Fix "uninitialized variable" warnings at -O2 Len Brown
@ 2019-08-31 19:34 ` Len Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Len Brown @ 2019-08-31 19:34 UTC (permalink / raw
  To: linux-pm; +Cc: Naoya Horiguchi, Len Brown

From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>

turbostat could be terminated by general protection fault on some latest
hardwares which (for example) support 9 levels of C-states and show 18
"tADDED" lines. That bloats the total output and finally causes buffer
overrun.  So let's extend the buffer to avoid this.

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 2fb5c155289b..f8f4e1c130a6 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -5131,7 +5131,7 @@ int initialize_counters(int cpu_id)
 
 void allocate_output_buffer()
 {
-	output_buffer = calloc(1, (1 + topo.num_cpus) * 1024);
+	output_buffer = calloc(1, (1 + topo.num_cpus) * 2048);
 	outp = output_buffer;
 	if (outp == NULL)
 		err(-1, "calloc output buffer");
-- 
2.20.1


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

* Re: [PATCH 09/19] tools/power turbostat: fix buffer overrun
       [not found] <eeb71c950bc6eee460f2070643ce137e067b234c.1567277326.git.len.brown () intel ! com>
@ 2019-09-16 15:09 ` Prarit Bhargava
  0 siblings, 0 replies; 2+ messages in thread
From: Prarit Bhargava @ 2019-09-16 15:09 UTC (permalink / raw
  To: Len Brown, Naoya Horiguchi, linux-pm@vger.kernel.org, Len Brown



On 8/31/19 3:34 PM, Len Brown wrote:
> From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> 
> turbostat could be terminated by general protection fault on some latest
> hardwares which (for example) support 9 levels of C-states and show 18
> "tADDED" lines. That bloats the total output and finally causes buffer
> overrun.  So let's extend the buffer to avoid this.
> 
> Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Signed-off-by: Len Brown <len.brown@intel.com>
> ---
>  tools/power/x86/turbostat/turbostat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
> index 2fb5c155289b..f8f4e1c130a6 100644
> --- a/tools/power/x86/turbostat/turbostat.c
> +++ b/tools/power/x86/turbostat/turbostat.c
> @@ -5131,7 +5131,7 @@ int initialize_counters(int cpu_id)
>  
>  void allocate_output_buffer()
>  {
> -	output_buffer = calloc(1, (1 + topo.num_cpus) * 1024);
> +	output_buffer = calloc(1, (1 + topo.num_cpus) * 2048);

While this "works" I'm not convinced it is a final fix. I think moving to the
proposal Naoya & I laid out would be better.

https://marc.info/?l=linux-pm&m=155809356001873&w=2

Len, what do you think?

P.

>  	outp = output_buffer;
>  	if (outp == NULL)
>  		err(-1, "calloc output buffer");
> 

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

end of thread, other threads:[~2019-09-16 15:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <eeb71c950bc6eee460f2070643ce137e067b234c.1567277326.git.len.brown () intel ! com>
2019-09-16 15:09 ` [PATCH 09/19] tools/power turbostat: fix buffer overrun Prarit Bhargava
2019-08-31 19:34 [PATCH 01/19] tools/power x86_energy_perf_policy: Fix "uninitialized variable" warnings at -O2 Len Brown
2019-08-31 19:34 ` [PATCH 09/19] tools/power turbostat: fix buffer overrun Len Brown

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.