powerpc/kexec: Fix memory corruption from unallocated slaves
commit9c9f2de51e46be3011a100b4b401a6f17d220776
authorMilton Miller <miltonm@bga.com>
Tue, 10 May 2011 19:28:33 +0000 (10 19:28 +0000)
committerAndi Kleen <ak@linux.intel.com>
Mon, 1 Aug 2011 20:54:50 +0000 (1 13:54 -0700)
treedbdadcc46e950a3569f209f188c202ce5cd78f60
parentc4e60bd6930b93a13432f53dfb70e65d8fef58d2
powerpc/kexec: Fix memory corruption from unallocated slaves

commit 3d2cea732d68aa270c360f55d8669820ebce188a upstream.

Commit 1fc711f7ffb01089efc58042cfdbac8573d1b59a (powerpc/kexec: Fix race
in kexec shutdown) moved the write to signal the cpu had exited the kernel
from before the transition to real mode in kexec_smp_wait to kexec_wait.

Unfornately it missed that kexec_wait is used both by cpus leaving the
kernel and by secondary slave cpus that were not allocated a paca for
what ever reason -- they could be beyond nr_cpus or not described in
the current device tree for whatever reason (for example, kexec-load
was not refreshed after a cpu hotplug operation).  Cpus coming through
that path they will write to paca[NR_CPUS] which is beyond the space
allocated for the paca data and overwrite memory not allocated to pacas
but very likely still real mode accessable).

Move the write back to kexec_smp_wait, which is used only by cpus that
found their paca, but after the transition to real mode.

Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
arch/powerpc/kernel/misc_64.S