]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: fix handling of save_stack_trace sentinel (x86 only)
authorKris Van Hees <kris.van.hees@oracle.com>
Mon, 3 Apr 2017 12:18:53 +0000 (08:18 -0400)
committerKris Van Hees <kris.van.hees@oracle.com>
Mon, 3 Apr 2017 16:11:53 +0000 (12:11 -0400)
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 <kris.van.hees@oracle.com>
Reviewed-by: Tomas Jedlicka <tomas.jedlicka@oracle.com>
kernel/dtrace/dtrace_os.c

index 72d0746748c65a00076cbb8a18726cb9ca81fad3..95afcd4151ab3ad1933248380ab65c9949a125be 100644 (file)
@@ -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