linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Len Brown <lenb@kernel.org>
To: linux-pm@vger.kernel.org
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
	Len Brown <len.brown@intel.com>
Subject: [PATCH 09/19] tools/power turbostat: fix buffer overrun
Date: Sat, 31 Aug 2019 15:34:48 -0400	[thread overview]
Message-ID: <eeb71c950bc6eee460f2070643ce137e067b234c.1567277326.git.len.brown@intel.com> (raw)
In-Reply-To: <adb8049097a9ec4acd09fbd3aa8636199a78df8a.1567277326.git.len.brown@intel.com>

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


  parent reply	other threads:[~2019-08-31 19:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-31 19:34 turbostat 19.08.31 is available Len Brown
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 02/19] tools/power/x86: Enable compiler optimisations and Fortify by default Len Brown
2019-08-31 19:34   ` [PATCH 03/19] tools/power: Fix typo in man page Len Brown
2019-08-31 19:34   ` [PATCH 04/19] tools/power x86_energy_perf_policy: Fix argument parsing Len Brown
2019-08-31 19:34   ` [PATCH 05/19] tools/power turbostat: remove duplicate pc10 column Len Brown
2019-08-31 19:34   ` [PATCH 06/19] tools/power turbostat: Make interval calculation per thread to reduce jitter Len Brown
2019-08-31 19:34   ` [PATCH 07/19] tools/power turbostat: fix leak of file descriptor on error return path Len Brown
2019-08-31 19:34   ` [PATCH 08/19] tools/power turbostat: fix file descriptor leaks Len Brown
2019-08-31 19:34   ` Len Brown [this message]
2019-08-31 19:34   ` [PATCH 10/19] tools/power turbostat: add Jacobsville support Len Brown
2019-08-31 19:34   ` [PATCH 11/19] tools/power turbostat: Fix Haswell Core systems Len Brown
2019-08-31 19:34   ` [PATCH 12/19] tools/power turbostat: rename has_hsw_msrs() Len Brown
2019-08-31 19:34   ` [PATCH 13/19] tools/power turbostat: Add Ice Lake NNPI support Len Brown
2019-08-31 19:34   ` [PATCH 14/19] tools/power turbostat: read from pipes too Len Brown
2019-08-31 19:34   ` [PATCH 15/19] tools/power turbostat: do not enforce 1ms Len Brown
2019-08-31 19:34   ` [PATCH 16/19] tools/power turbostat: Fix CPU%C1 display value Len Brown
2019-08-31 19:34   ` [PATCH 17/19] tools/power turbostat: Fix caller parameter of get_tdp_amd() Len Brown
2019-08-31 19:34   ` [PATCH 18/19] tools/power turbostat: Add support for Hygon Fam 18h (Dhyana) RAPL Len Brown
2019-08-31 19:34   ` [PATCH 19/19] tools/power turbostat: update version number Len Brown
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eeb71c950bc6eee460f2070643ce137e067b234c.1567277326.git.len.brown@intel.com \
    --to=lenb@kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=n-horiguchi@ah.jp.nec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).