Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2472593pxj; Mon, 10 May 2021 03:57:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTSgmUAKRpm2v2quXz4KN6I+hT1HkF0lECzOlbXThojkSUeIHQsmfdO/ikNpHP/9tUxZAn X-Received: by 2002:a05:6638:1648:: with SMTP id a8mr20844450jat.25.1620644259435; Mon, 10 May 2021 03:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644259; cv=none; d=google.com; s=arc-20160816; b=ZuB+lwRhgUOFrnoYl5w8q0gHGIGLfO8Lxi85a/25rgozKZBX1I4z2Eqk2aLHaiS1IA 78qyByfTcV2KG6cmbrvsp3Eutt64/e+PreQj5l+Usj9nePj2LhmFsKkSWsTrp3H3Drn9 qOknIO+vS1M0ZqBsnXwL3NMFNhe9cuK9uvTzAl0iDSJaV+QFBx4YOY5pP0tLRgK4dN0W zivJarTec10wyyKjASOCbhP9Fv0JM3uuByc3FRWTu1YnysLumhLBugb3st1p25+//lnq JKoZF/laL7XrMOUoRnvKXJdKHHaV4aZOaOpe3+EMzTcrIogZkd3TZEu1OuvaKD2JsNxv 1JQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V5k7CI3YJKY0HAb3hMi0y/IVD12WOYVmnxWhlau3g80=; b=KcnW69jra5sm6RpgzMDrM1KQwwXCogUKIWd1OP/Z7kCoDxsGC5xkyKLLapbTrzr+Qn xsV0QIkudMFHkYDgQ7CYQGkf56FUSl4AL0YODe7/20mQjfgfoFryluuvai9viIFyXS0G r07YAXr+cOFJ651BlAVEn0/EMtP5pHVSNajW9pg0EUAOsefVMDAqKKKIQgqN27NJ7yM/ keY+a++oh9XGIr3P6l8s6PuZV45rGzNVURMHVT7OEbGSD96mzwGtcJIgOMw+HtT0Cxse WPVWpzXgl4CctxiP/w3kvGPU6L51cmBQYhKh4+VedKxNxSUUulKI+hUTfyUHI0WmAGye aB6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pKZk59gX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si14869114ilq.150.2021.05.10.03.57.27; Mon, 10 May 2021 03:57:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pKZk59gX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234873AbhEJK5M (ORCPT + 99 others); Mon, 10 May 2021 06:57:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:57592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbhEJKpC (ORCPT ); Mon, 10 May 2021 06:45:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 81E6A6162C; Mon, 10 May 2021 10:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642880; bh=cFzoFc2FSTUDTJ9I0MNr5aMOG8GsOPwuxgKpJxNMDgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pKZk59gXgrh+wRFOEI2iPcO/swRNMQkLTaPF82oBCGbTQ7kaWDO5emCa3ghlKPujL rmPYw+i3K+E80B37ZhNa1GmhhWeCZ+ejFv3hyuchsUGiLljHONGrxefEYhtqLQ1QRA RCN/2m8pmcLHM5GsKJzFwmX0Du65PKuf5OOJXT3s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Pandruvada , Hans de Goede , Sasha Levin Subject: [PATCH 5.10 090/299] tools/power/x86/intel-speed-select: Increase string size Date: Mon, 10 May 2021 12:18:07 +0200 Message-Id: <20210510102007.921585944@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Pandruvada [ Upstream commit 2e70b710f36c80b6e78cf32a5c30b46dbb72213c ] The current string size to print cpulist can accommodate upto 80 logical CPUs per package. But this limit is not enough. So increase the string size. Also prevent buffer overflow, if the string size reaches limit. Signed-off-by: Srinivas Pandruvada Signed-off-by: Hans de Goede Signed-off-by: Sasha Levin --- tools/power/x86/intel-speed-select/isst-display.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-display.c b/tools/power/x86/intel-speed-select/isst-display.c index e105fece47b6..f32ce0362eb7 100644 --- a/tools/power/x86/intel-speed-select/isst-display.c +++ b/tools/power/x86/intel-speed-select/isst-display.c @@ -25,10 +25,14 @@ static void printcpulist(int str_len, char *str, int mask_size, index = snprintf(&str[curr_index], str_len - curr_index, ","); curr_index += index; + if (curr_index >= str_len) + break; } index = snprintf(&str[curr_index], str_len - curr_index, "%d", i); curr_index += index; + if (curr_index >= str_len) + break; first = 0; } } @@ -64,10 +68,14 @@ static void printcpumask(int str_len, char *str, int mask_size, index = snprintf(&str[curr_index], str_len - curr_index, "%08x", mask[i]); curr_index += index; + if (curr_index >= str_len) + break; if (i) { strncat(&str[curr_index], ",", str_len - curr_index); curr_index++; } + if (curr_index >= str_len) + break; } free(mask); @@ -185,7 +193,7 @@ static void _isst_pbf_display_information(int cpu, FILE *outf, int level, int disp_level) { char header[256]; - char value[256]; + char value[512]; snprintf(header, sizeof(header), "speed-select-base-freq-properties"); format_and_print(outf, disp_level, header, NULL); @@ -349,7 +357,7 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level, struct isst_pkg_ctdp *pkg_dev) { char header[256]; - char value[256]; + char value[512]; static int level; int i; -- 2.30.2