arm64: stacktrace: Better handle corrupted stacks
authorMark Rutland <mark.rutland@arm.com>
Tue, 2 Jul 2019 13:07:29 +0000 (14:07 +0100)
committerWill Deacon <will@kernel.org>
Mon, 22 Jul 2019 10:44:15 +0000 (11:44 +0100)
commit592700f094be229b5c9cc1192d5cea46eb4c7afc
tree94b98dd3d350970646a4d5d40227daa00d645945
parentf3dcbe67ed424f1cf92065f9ad0cc647f2b44eac
arm64: stacktrace: Better handle corrupted stacks

The arm64 stacktrace code is careful to only dereference frame records
in valid stack ranges, ensuring that a corrupted frame record won't
result in a faulting access.

However, it's still possible for corrupt frame records to result in
infinite loops in the stacktrace code, which is also undesirable.

This patch ensures that we complete a stacktrace in finite time, by
keeping track of which stacks we have already completed unwinding, and
verifying that if the next frame record is on the same stack, it is at a
higher address.

As this has turned out to be particularly subtle, comments are added to
explain the procedure.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: James Morse <james.morse@arm.com>
Tested-by: James Morse <james.morse@arm.com>
Acked-by: Dave Martin <Dave.Martin@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Tengfei Fan <tengfeif@codeaurora.org>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/stacktrace.h
arch/arm64/kernel/stacktrace.c