@@ -32,6 +32,7 @@ struct stack_info {
enum unwind_rc {
UNWIND_CONTINUE, /* No errors encountered */
+ UNWIND_CONTINUE_WITH_RISK, /* Non-fatal errors encountered */
UNWIND_ABORT, /* Fatal errors encountered */
UNWIND_FINISH, /* End of stack reached successfully */
};
@@ -73,6 +74,7 @@ extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame,
bool (*fn)(void *, unsigned long), void *data);
extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
const char *loglvl);
+extern enum unwind_rc unwind_check_frame(struct stackframe *frame);
DECLARE_PER_CPU(unsigned long *, irq_stack_ptr);
@@ -176,7 +178,7 @@ static inline enum unwind_rc start_backtrace(struct stackframe *frame,
bitmap_zero(frame->stacks_done, __NR_STACK_TYPES);
frame->prev_fp = 0;
frame->prev_type = STACK_TYPE_UNKNOWN;
- return UNWIND_CONTINUE;
+ return unwind_check_frame(frame);
}
#endif /* __ASM_STACKTRACE_H */
@@ -18,6 +18,21 @@
#include <asm/stack_pointer.h>
#include <asm/stacktrace.h>
+/*
+ * Check the stack frame for conditions that make unwinding unreliable.
+ */
+enum unwind_rc unwind_check_frame(struct stackframe *frame)
+{
+ /*
+ * If the PC is not a known kernel text address, then we cannot
+ * be sure that a subsequent unwind will be reliable, as we
+ * don't know that the code follows our unwind requirements.
+ */
+ if (!__kernel_text_address(frame->pc))
+ return UNWIND_CONTINUE_WITH_RISK;
+ return UNWIND_CONTINUE;
+}
+
/*
* AArch64 PCS assigns the frame pointer to x29.
*
@@ -109,7 +124,7 @@ enum unwind_rc notrace unwind_frame(struct task_struct *tsk,
frame->pc = ptrauth_strip_insn_pac(frame->pc);
- return UNWIND_CONTINUE;
+ return unwind_check_frame(frame);
}
NOKPROBE_SYMBOL(unwind_frame);