Commit 4a33691c authored by Zeng Tao's avatar Zeng Tao Committed by Greg Kroah-Hartman

cpu-topology: Fix the potential data corruption

Currently there are only 10 bytes to store the cpu-topology 'name'
information. Only 10 bytes copied into cluster/thread/core names.

If the cluster ID exceeds 2-digit number, it will result in the data
corruption, and ending up in a dead loop in the parsing routines. The
same applies to the thread names with more that 3-digit number.

This issue was found using the boundary tests under virtualised
environment like QEMU.

Let us increase the buffer to fix such potential issues.
Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
Signed-off-by: default avatarZeng Tao <prime.zeng@hisilicon.com>

Link: https://lore.kernel.org/r/1583294092-5929-1-git-send-email-prime.zeng@hisilicon.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b8fe128d
...@@ -297,7 +297,7 @@ static int __init get_cpu_for_node(struct device_node *node) ...@@ -297,7 +297,7 @@ static int __init get_cpu_for_node(struct device_node *node)
static int __init parse_core(struct device_node *core, int package_id, static int __init parse_core(struct device_node *core, int package_id,
int core_id) int core_id)
{ {
char name[10]; char name[20];
bool leaf = true; bool leaf = true;
int i = 0; int i = 0;
int cpu; int cpu;
...@@ -343,7 +343,7 @@ static int __init parse_core(struct device_node *core, int package_id, ...@@ -343,7 +343,7 @@ static int __init parse_core(struct device_node *core, int package_id,
static int __init parse_cluster(struct device_node *cluster, int depth) static int __init parse_cluster(struct device_node *cluster, int depth)
{ {
char name[10]; char name[20];
bool leaf = true; bool leaf = true;
bool has_cores = false; bool has_cores = false;
struct device_node *c; struct device_node *c;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment