arm64: Survive invalid cpu enable-methods
authorMark Rutland <mark.rutland@arm.com>
Tue, 23 Apr 2013 16:22:49 +0000 (17:22 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 25 Apr 2013 16:45:54 +0000 (17:45 +0100)
commit47ae38932be84ec3fbf4530b95b3c09fa371e5be
treed8a153f03d0a47872729c6cff6b00191da220593
parent0c2ca5dc0398066ba451a047a7f18b9f009d1c31
arm64: Survive invalid cpu enable-methods

Currently, if you pass the kernel a dtb where a cpu node has an
unsupported enable-method property (e.g. "not-psci"), it'll explode
horribly, as it iterates over the enable_ops array incorrectly. It
increments the pointer *at* the current element, rather than
incrementing the pointer *to* the current element. As the first two
elements pointed to structures that were contiguous in memory, this
happened to be equivalent. However the third element is NULL, so when
the list is exhausted, smp_get_enable_ops generates the wrong pointer,
and dereferences an arbitrary portion of memory, which currently happens
to contain zero.

This patch fixes this by indirecting the pointer one level, so we
iterate over the array elements correctly, avoiding the below panic:

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/smp.c