Skip to content

Commit 460511c

Browse files
neosys007vineetgarc
authored andcommitted
arc: validate DT CPU map strings before parsing them
arc_get_cpu_map() fetches the possible-cpus or present-cpus property from the flat DT and immediately passes the raw pointer to cpulist_parse(). That parser expects a NUL-terminated text buffer, but this path does not prove that the DT property is terminated within its declared bounds. Reject unterminated CPU-map properties before handing them to cpulist_parse(). Changes since v1: - fold the NUL-termination check into the initial lookup test, as suggested by Vineet Gupta Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn> Signed-off-by: Vineet Gupta <vgupta@kernel.org>
1 parent 8cdeaa5 commit 460511c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

arch/arc/kernel/smp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/irqdomain.h>
2323
#include <linux/export.h>
2424
#include <linux/of_fdt.h>
25+
#include <linux/string.h>
2526

2627
#include <asm/mach_desc.h>
2728
#include <asm/setup.h>
@@ -43,9 +44,10 @@ static int __init arc_get_cpu_map(const char *name, struct cpumask *cpumask)
4344
{
4445
unsigned long dt_root = of_get_flat_dt_root();
4546
const char *buf;
47+
int len;
4648

47-
buf = of_get_flat_dt_prop(dt_root, name, NULL);
48-
if (!buf)
49+
buf = of_get_flat_dt_prop(dt_root, name, &len);
50+
if (!buf || !memchr(buf, '\0', len))
4951
return -EINVAL;
5052

5153
if (cpulist_parse(buf, cpumask))

0 commit comments

Comments
 (0)