ARM: 6884/1: Fix infinite loop in ARM user perf_event backtrace code

The ARM user backtrace code can get into an infinite loop if it
runs into an invalid stack frame which points back to itself.
This situation has been observed in practice. Fix it by capping
the number of entries in the backtrace. This is also what other
architectures do in their backtrace code.

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Acked-by: Jamie Iles <jamie@jamieiles.com>
Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Sonny Rao and committed by Russell King 860ad782 167f8297

+2 -1
+2 -1
arch/arm/kernel/perf_event.c
··· 746 746 747 747 tail = (struct frame_tail __user *)regs->ARM_fp - 1; 748 748 749 - while (tail && !((unsigned long)tail & 0x3)) 749 + while ((entry->nr < PERF_MAX_STACK_DEPTH) && 750 + tail && !((unsigned long)tail & 0x3)) 750 751 tail = user_backtrace(tail, entry); 751 752 } 752 753