From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99F2FC3A5A6 for ; Thu, 19 Sep 2019 22:21:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6E5DE21927 for ; Thu, 19 Sep 2019 22:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931666; bh=fSg4w60wGc2fe1to3ZNBO/o5AAysdACtKnyKU+ecgZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PYvA23foOFD0QUscDPc3YxaDWsJ8UkxOeIk9bfNkKH04bBTOrBRP6LsANLxSsz4/g eNEN1x/XERN2uF9xZHrlXL55/Bi7sHiPdpJDMM4NgLUd0c/7y3UUrY5i2hQbqbj4kA OrtD+1YkCVuscoc7TTZDsL4M2Ne61JEKBVAT2KOY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406673AbfISWVF (ORCPT ); Thu, 19 Sep 2019 18:21:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:35228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405537AbfISWU5 (ORCPT ); Thu, 19 Sep 2019 18:20:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 584F621927; Thu, 19 Sep 2019 22:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931656; bh=fSg4w60wGc2fe1to3ZNBO/o5AAysdACtKnyKU+ecgZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mp4/gN+sgWMAh3HXPbM1WxoszUvgsiZqnbQyPnL2siFfy9w169blPWQ22PY2mmE+u ncRwRC7P8B2BfC55AoNJoiTcE20EQxjV2GrVf5EhUOWEhgEVoQRzhfDLRPl92fN8ni TxjSi2XEWEUZJxMVbwORFTl5iYY9m4O1Of6I2Wtg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Naoya Horiguchi , Len Brown , Sasha Levin Subject: [PATCH 4.9 65/74] tools/power turbostat: fix buffer overrun Date: Fri, 20 Sep 2019 00:04:18 +0200 Message-Id: <20190919214810.836446342@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214800.519074117@linuxfoundation.org> References: <20190919214800.519074117@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naoya Horiguchi [ Upstream commit eeb71c950bc6eee460f2070643ce137e067b234c ] 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 Signed-off-by: Len Brown Signed-off-by: Sasha Levin --- 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 b4c5d96e54c12..7c2c8e74aa9a9 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -3593,7 +3593,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