Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <groug@kaod.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/161531347060.252863.10490063933688958044.stgit@bahia.lan

authored by

Greg Kurz and committed by
Michael Ellerman
8873aab8 c3710ee7

+3 -3
+3 -3
arch/powerpc/xmon/xmon.c
··· 1350 1350 } 1351 1351 termch = cpu; 1352 1352 1353 - if (!scanhex(&cpu)) { 1353 + if (!scanhex(&cpu) || cpu >= num_possible_cpus()) { 1354 1354 /* print cpus waiting or in xmon */ 1355 1355 printf("cpus stopped:"); 1356 1356 last_cpu = first_cpu = NR_CPUS; ··· 2772 2772 2773 2773 termch = c; /* Put c back, it wasn't 'a' */ 2774 2774 2775 - if (scanhex(&num)) 2775 + if (scanhex(&num) && num < num_possible_cpus()) 2776 2776 dump_one_paca(num); 2777 2777 else 2778 2778 dump_one_paca(xmon_owner); ··· 2845 2845 2846 2846 termch = c; /* Put c back, it wasn't 'a' */ 2847 2847 2848 - if (scanhex(&num)) 2848 + if (scanhex(&num) && num < num_possible_cpus()) 2849 2849 dump_one_xive(num); 2850 2850 else 2851 2851 dump_one_xive(xmon_owner);