All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/xmon: Check cpu id in commands "c#", "dp#" and "dx#"
@ 2021-03-09 18:11 Greg Kurz
  2021-03-10 11:18 ` Cédric Le Goater
  2024-05-08 13:39 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Greg Kurz @ 2021-03-09 18:11 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Cédric Le Goater

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>
---
 arch/powerpc/xmon/xmon.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 80fbf8968f77..d3d6e044228e 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1248,7 +1248,7 @@ static int cpu_cmd(void)
 	unsigned long cpu, first_cpu, last_cpu;
 	int timeout;
 
-	if (!scanhex(&cpu)) {
+	if (!scanhex(&cpu) || cpu >= num_possible_cpus()) {
 		/* print cpus waiting or in xmon */
 		printf("cpus stopped:");
 		last_cpu = first_cpu = NR_CPUS;
@@ -2678,7 +2678,7 @@ static void dump_pacas(void)
 
 	termch = c;	/* Put c back, it wasn't 'a' */
 
-	if (scanhex(&num))
+	if (scanhex(&num) && num < num_possible_cpus())
 		dump_one_paca(num);
 	else
 		dump_one_paca(xmon_owner);
@@ -2751,7 +2751,7 @@ static void dump_xives(void)
 
 	termch = c;	/* Put c back, it wasn't 'a' */
 
-	if (scanhex(&num))
+	if (scanhex(&num) && num < num_possible_cpus())
 		dump_one_xive(num);
 	else
 		dump_one_xive(xmon_owner);



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/xmon: Check cpu id in commands "c#", "dp#" and "dx#"
  2021-03-09 18:11 [PATCH] powerpc/xmon: Check cpu id in commands "c#", "dp#" and "dx#" Greg Kurz
@ 2021-03-10 11:18 ` Cédric Le Goater
  2024-05-08 13:39 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Cédric Le Goater @ 2021-03-10 11:18 UTC (permalink / raw)
  To: Greg Kurz, linuxppc-dev

On 3/9/21 7:11 PM, Greg Kurz wrote:
> 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>


> ---
>  arch/powerpc/xmon/xmon.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index 80fbf8968f77..d3d6e044228e 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -1248,7 +1248,7 @@ static int cpu_cmd(void)
>  	unsigned long cpu, first_cpu, last_cpu;
>  	int timeout;
>  
> -	if (!scanhex(&cpu)) {
> +	if (!scanhex(&cpu) || cpu >= num_possible_cpus()) {
>  		/* print cpus waiting or in xmon */
>  		printf("cpus stopped:");
>  		last_cpu = first_cpu = NR_CPUS;
> @@ -2678,7 +2678,7 @@ static void dump_pacas(void)
>  
>  	termch = c;	/* Put c back, it wasn't 'a' */
>  
> -	if (scanhex(&num))
> +	if (scanhex(&num) && num < num_possible_cpus())
>  		dump_one_paca(num);
>  	else
>  		dump_one_paca(xmon_owner);
> @@ -2751,7 +2751,7 @@ static void dump_xives(void)
>  
>  	termch = c;	/* Put c back, it wasn't 'a' */
>  
> -	if (scanhex(&num))
> +	if (scanhex(&num) && num < num_possible_cpus())
>  		dump_one_xive(num);
>  	else
>  		dump_one_xive(xmon_owner);
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/xmon: Check cpu id in commands "c#", "dp#" and "dx#"
  2021-03-09 18:11 [PATCH] powerpc/xmon: Check cpu id in commands "c#", "dp#" and "dx#" Greg Kurz
  2021-03-10 11:18 ` Cédric Le Goater
@ 2024-05-08 13:39 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2024-05-08 13:39 UTC (permalink / raw)
  To: linuxppc-dev, Greg Kurz; +Cc: Cédric Le Goater

On Tue, 09 Mar 2021 19:11:10 +0100, Greg Kurz wrote:
> 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.
> 
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/xmon: Check cpu id in commands "c#", "dp#" and "dx#"
      https://git.kernel.org/powerpc/c/8873aab8646194a4446117bb617cc71bddda2dee

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-08 13:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 18:11 [PATCH] powerpc/xmon: Check cpu id in commands "c#", "dp#" and "dx#" Greg Kurz
2021-03-10 11:18 ` Cédric Le Goater
2024-05-08 13:39 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.