arm64: kprobes: Fix overflow when saving stack
authorMarc Zyngier <marc.zyngier@arm.com>
Thu, 29 Sep 2016 22:18:23 +0000 (18:18 -0400)
committerAlex Shi <alex.shi@linaro.org>
Thu, 20 Oct 2016 07:38:13 +0000 (15:38 +0800)
commit71b5200f5f0c1e9966dd7d238526e85f4fbf8089
tree646ad74f9223604b1fb76820dfd8cc86e83d48cd
parenta1961c0da3b0e3fa8bd803547f96963bf31b69a4
arm64: kprobes: Fix overflow when saving stack

commit ab4c1325d4bf111a590a1f773e3d93bde7f40201 upstream.

The MIN_STACK_SIZE macro tries evaluate how much stack space needs
to be saved in the jprobes_stack array, sized at 128 bytes.

When using the IRQ stack, said macro can happily return up to
IRQ_STACK_SIZE, which is 16kB. Mayhem follows.

This patch fixes things by getting rid of the crazy macro and
limiting the copy to be at most the size of the jprobes_stack
array, no matter which stack we're on.

[dave.long@linaro.org: Since there is no irq_stack in this kernel version
this fix is not strictly necessary, but is included for completeness.]

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: David A. Long <dave.long@linaro.org>
arch/arm64/kernel/probes/kprobes.c