linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: fix memory corruption by pnv_alloc_idle_core_states
@ 2015-03-31 16:11 Jan Stancek
  2015-04-01  2:40 ` Michael Ellerman
  2015-04-01  9:37 ` Preeti U Murthy
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Stancek @ 2015-03-31 16:11 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: linux-kernel, benh, paulus, mpe, mikey, jstancek, shreyas, preeti, sbest

Space allocated for paca is based off nr_cpu_ids,
but pnv_alloc_idle_core_states() iterates paca with
cpu_nr_cores()*threads_per_core, which is using NR_CPUS.

This causes pnv_alloc_idle_core_states() to write over memory,
which is outside of paca array and may later lead to various panics.

Fixes: 7cba160ad789 (powernv/cpuidle: Redesign idle states management)
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 arch/powerpc/include/asm/cputhreads.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/cputhreads.h b/arch/powerpc/include/asm/cputhreads.h
index 2bf8e93..4c8ad59 100644
--- a/arch/powerpc/include/asm/cputhreads.h
+++ b/arch/powerpc/include/asm/cputhreads.h
@@ -55,7 +55,7 @@ static inline cpumask_t cpu_thread_mask_to_cores(const struct cpumask *threads)
 
 static inline int cpu_nr_cores(void)
 {
-	return NR_CPUS >> threads_shift;
+	return nr_cpu_ids >> threads_shift;
 }
 
 static inline cpumask_t cpu_online_cores_map(void)
-- 
1.8.3.1


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

* Re: [PATCH] powerpc: fix memory corruption by pnv_alloc_idle_core_states
  2015-03-31 16:11 [PATCH] powerpc: fix memory corruption by pnv_alloc_idle_core_states Jan Stancek
@ 2015-04-01  2:40 ` Michael Ellerman
  2015-04-01  9:37 ` Preeti U Murthy
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2015-04-01  2:40 UTC (permalink / raw)
  To: Jan Stancek
  Cc: linuxppc-dev, linux-kernel, benh, paulus, mikey, shreyas, preeti, sbest

On Tue, 2015-03-31 at 18:11 +0200, Jan Stancek wrote:
> Space allocated for paca is based off nr_cpu_ids,
> but pnv_alloc_idle_core_states() iterates paca with
> cpu_nr_cores()*threads_per_core, which is using NR_CPUS.
> 
> This causes pnv_alloc_idle_core_states() to write over memory,
> which is outside of paca array and may later lead to various panics.
> 
> Fixes: 7cba160ad789 (powernv/cpuidle: Redesign idle states management)
> Signed-off-by: Jan Stancek <jstancek@redhat.com>

Thanks. I'll send that to Linus in the next day or two and mark it for stable
as well.

cheers



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

* Re: [PATCH] powerpc: fix memory corruption by pnv_alloc_idle_core_states
  2015-03-31 16:11 [PATCH] powerpc: fix memory corruption by pnv_alloc_idle_core_states Jan Stancek
  2015-04-01  2:40 ` Michael Ellerman
@ 2015-04-01  9:37 ` Preeti U Murthy
  1 sibling, 0 replies; 3+ messages in thread
From: Preeti U Murthy @ 2015-04-01  9:37 UTC (permalink / raw)
  To: Jan Stancek, linuxppc-dev, mpe
  Cc: linux-kernel, benh, paulus, mikey, shreyas, sbest

On 03/31/2015 09:41 PM, Jan Stancek wrote:
> Space allocated for paca is based off nr_cpu_ids,
> but pnv_alloc_idle_core_states() iterates paca with
> cpu_nr_cores()*threads_per_core, which is using NR_CPUS.
> 
> This causes pnv_alloc_idle_core_states() to write over memory,
> which is outside of paca array and may later lead to various panics.
> 
> Fixes: 7cba160ad789 (powernv/cpuidle: Redesign idle states management)
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
>  arch/powerpc/include/asm/cputhreads.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/include/asm/cputhreads.h b/arch/powerpc/include/asm/cputhreads.h
> index 2bf8e93..4c8ad59 100644
> --- a/arch/powerpc/include/asm/cputhreads.h
> +++ b/arch/powerpc/include/asm/cputhreads.h
> @@ -55,7 +55,7 @@ static inline cpumask_t cpu_thread_mask_to_cores(const struct cpumask *threads)
> 
>  static inline int cpu_nr_cores(void)
>  {
> -	return NR_CPUS >> threads_shift;
> +	return nr_cpu_ids >> threads_shift;
>  }

Thanks for the patch!

Reviewed-by: Preeti U. Murthy <preeti@linux.vnet.ibm.com>
> 
>  static inline cpumask_t cpu_online_cores_map(void)
> 


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

end of thread, other threads:[~2015-04-01  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-31 16:11 [PATCH] powerpc: fix memory corruption by pnv_alloc_idle_core_states Jan Stancek
2015-04-01  2:40 ` Michael Ellerman
2015-04-01  9:37 ` Preeti U Murthy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).