提交 5a7bc154 编写于 作者: S Srinivas Pandruvada 提交者: Zheng Zengkai

tools/power/x86/intel-speed-select: Increase string size

stable inclusion
from stable-5.10.36
commit bc900a7ccdd40a138a92eedf8bdff607a0a24f6e
bugzilla: 51867
CVE: NA

--------------------------------

[ Upstream commit 2e70b710 ]

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: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: NHans de Goede <hdegoede@redhat.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 b9fa3b62
...@@ -25,10 +25,14 @@ static void printcpulist(int str_len, char *str, int mask_size, ...@@ -25,10 +25,14 @@ static void printcpulist(int str_len, char *str, int mask_size,
index = snprintf(&str[curr_index], index = snprintf(&str[curr_index],
str_len - curr_index, ","); str_len - curr_index, ",");
curr_index += index; curr_index += index;
if (curr_index >= str_len)
break;
} }
index = snprintf(&str[curr_index], str_len - curr_index, "%d", index = snprintf(&str[curr_index], str_len - curr_index, "%d",
i); i);
curr_index += index; curr_index += index;
if (curr_index >= str_len)
break;
first = 0; first = 0;
} }
} }
...@@ -64,10 +68,14 @@ static void printcpumask(int str_len, char *str, int mask_size, ...@@ -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", index = snprintf(&str[curr_index], str_len - curr_index, "%08x",
mask[i]); mask[i]);
curr_index += index; curr_index += index;
if (curr_index >= str_len)
break;
if (i) { if (i) {
strncat(&str[curr_index], ",", str_len - curr_index); strncat(&str[curr_index], ",", str_len - curr_index);
curr_index++; curr_index++;
} }
if (curr_index >= str_len)
break;
} }
free(mask); free(mask);
...@@ -185,7 +193,7 @@ static void _isst_pbf_display_information(int cpu, FILE *outf, int level, ...@@ -185,7 +193,7 @@ static void _isst_pbf_display_information(int cpu, FILE *outf, int level,
int disp_level) int disp_level)
{ {
char header[256]; char header[256];
char value[256]; char value[512];
snprintf(header, sizeof(header), "speed-select-base-freq-properties"); snprintf(header, sizeof(header), "speed-select-base-freq-properties");
format_and_print(outf, disp_level, header, NULL); format_and_print(outf, disp_level, header, NULL);
...@@ -349,7 +357,7 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level, ...@@ -349,7 +357,7 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
struct isst_pkg_ctdp *pkg_dev) struct isst_pkg_ctdp *pkg_dev)
{ {
char header[256]; char header[256];
char value[256]; char value[512];
static int level; static int level;
int i; int i;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册