From: Kris Van Hees Date: Mon, 3 Apr 2017 12:18:53 +0000 (-0400) Subject: dtrace: fix handling of save_stack_trace sentinel (x86 only) X-Git-Tag: v4.1.12-98.0.20170517_2143~35^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=06c6bae4f7ff9220edbc95143592f241097ab152;p=users%2Fjedix%2Flinux-maple.git dtrace: fix handling of save_stack_trace sentinel (x86 only) On x86 only, when save_stack_trace() writes less stack frames to the buffer than there is space for, a ULONG_MAX is added as sentinel. The DTrace code was mistakenly treating the buffer as always ending with a ULONG_MAX. Orabug: 25727046 Signed-off-by: Kris Van Hees Reviewed-by: Tomas Jedlicka --- diff --git a/kernel/dtrace/dtrace_os.c b/kernel/dtrace/dtrace_os.c index 72d0746748c6..95afcd4151ab 100644 --- a/kernel/dtrace/dtrace_os.c +++ b/kernel/dtrace/dtrace_os.c @@ -464,10 +464,14 @@ void dtrace_stacktrace(stacktrace_state_t *st) * on x86_64 adds a ULONG_MAX entry after the last stack trace entry. * This might be a sentinel value, but given that struct stack_trace * already contains a nr_entries counter, this seems rather pointless. - * Alas, we need to add a special case for that... + * Alas, we need to add a special case for that... And to make matters + * worse, it actually does this only when there is room for it (i.e. + * when nr_entries < max_entries). + * Since ULONG_MAX inever a valid PC, we can just check for that. */ #ifdef CONFIG_X86_64 - st->depth = trace.nr_entries - 1; + if (trace.nr_entries && st->pcs[trace.nr_entries - 1] == ULONG_MAX) + st->depth = trace.nr_entries - 1; #else st->depth = trace.nr_entries; #endif