/* * Stack trace utility functions etc. * * Copyright 2008 Christoph Hellwig, IBM Corp. * Copyright 2018 SUSE Linux GmbH * Copyright 2018 Nick Piggin, Michael Ellerman, IBM Corp.
*/
newsp = stack[0];
ip = stack[STACK_FRAME_LR_SAVE];
if (!consume_entry(cookie, ip)) return;
sp = newsp;
}
}
/* * This function returns an error if it detects any unreliable features of the * stack. Otherwise it guarantees that the stack trace is reliable. * * If the task is not 'current', the caller *must* ensure the task is inactive.
*/ int __no_sanitize_address arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, void *cookie, struct task_struct *task)
{ unsignedlong sp; unsignedlong newsp; unsignedlong stack_page = (unsignedlong)task_stack_page(task); unsignedlong stack_end; int graph_idx = 0; bool firstframe;
stack_end = stack_page + THREAD_SIZE;
// See copy_thread() for details. if (task->flags & PF_KTHREAD)
stack_end -= STACK_FRAME_MIN_SIZE; else
stack_end -= STACK_USER_INT_FRAME_SIZE;
/* sanity check: ABI requires SP to be aligned 16 bytes. */ if (sp & 0xF) return -EINVAL;
newsp = stack[0]; /* Stack grows downwards; unwinder may only go up. */ if (newsp <= sp) return -EINVAL;
if (newsp != stack_end &&
newsp > stack_end - STACK_FRAME_MIN_SIZE) { return -EINVAL; /* invalid backlink, too far up. */
}
/* * We can only trust the bottom frame's backlink, the * rest of the frame may be uninitialized, continue to * the next.
*/ if (firstframe) continue;
/* Mark stacktraces with exception frames as unreliable. */ if (sp <= stack_end - STACK_INT_FRAME_SIZE &&
stack[STACK_INT_FRAME_MARKER_LONGS] == STACK_FRAME_REGS_MARKER) { return -EINVAL;
}
/* Examine the saved LR: it must point into kernel code. */
ip = stack[STACK_FRAME_LR_SAVE]; if (!__kernel_text_address(ip)) return -EINVAL;
/* * FIXME: IMHO these tests do not belong in * arch-dependent code, they are generic.
*/
ip = ftrace_graph_ret_addr(task, &graph_idx, ip, stack);
/* * Mark stacktraces with kretprobed functions on them * as unreliable.
*/ #ifdef CONFIG_RETHOOK if (ip == (unsignedlong)arch_rethook_trampoline) return -EINVAL; #endif
if (!consume_entry(cookie, ip)) return -EINVAL;
} return 0;
}
if (smp_send_safe_nmi_ipi(cpu, handle_backtrace_ipi, delay_us)) { // Now wait up to 5s for the other CPU to do its backtrace while (cpumask_test_cpu(cpu, mask) && delay_us) {
udelay(1);
delay_us--;
}
// Other CPU cleared itself from the mask if (delay_us) continue;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.21Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.