Skip to content

Commit 8873aab

Browse files
gkurzmpe
authored andcommitted
powerpc/xmon: Check cpu id in commands "c#", "dp#" and "dx#"
All these commands end up peeking into the PACA using the user originated cpu id as an index. Check the cpu id is valid in order to prevent xmon to crash. Instead of printing an error, this follows the same behavior as the "lp s #" command : ignore the buggy cpu id parameter and fall back to the #-less version of the command. Signed-off-by: Greg Kurz <[email protected]> Reviewed-by: Cédric Le Goater <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent c3710ee commit 8873aab

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/powerpc/xmon/xmon.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ static int cpu_cmd(void)
13501350
}
13511351
termch = cpu;
13521352

1353-
if (!scanhex(&cpu)) {
1353+
if (!scanhex(&cpu) || cpu >= num_possible_cpus()) {
13541354
/* print cpus waiting or in xmon */
13551355
printf("cpus stopped:");
13561356
last_cpu = first_cpu = NR_CPUS;
@@ -2772,7 +2772,7 @@ static void dump_pacas(void)
27722772

27732773
termch = c; /* Put c back, it wasn't 'a' */
27742774

2775-
if (scanhex(&num))
2775+
if (scanhex(&num) && num < num_possible_cpus())
27762776
dump_one_paca(num);
27772777
else
27782778
dump_one_paca(xmon_owner);
@@ -2845,7 +2845,7 @@ static void dump_xives(void)
28452845

28462846
termch = c; /* Put c back, it wasn't 'a' */
28472847

2848-
if (scanhex(&num))
2848+
if (scanhex(&num) && num < num_possible_cpus())
28492849
dump_one_xive(num);
28502850
else
28512851
dump_one_xive(xmon_owner);

0 commit comments

Comments
 (0)