Check stack pointer if we are reaching the stack end and stop unwinding if we do. This fixes early backtraces and avoids showing unrealistic call stacks.
···1414#include <linux/slab.h>1515#include <linux/kallsyms.h>1616#include <linux/sort.h>1717+#include <linux/sched.h>17181819#include <linux/uaccess.h>1920#include <asm/assembly.h>···280279281280 info->prev_sp = sp - 64;282281 info->prev_ip = 0;282282+283283+ /* The stack is at the end inside the thread_union284284+ * struct. If we reach data, we have reached the285285+ * beginning of the stack and should stop unwinding. */286286+ if (info->prev_sp >= (unsigned long) task_thread_info(info->t) &&287287+ info->prev_sp < ((unsigned long) task_thread_info(info->t)288288+ + THREAD_SZ_ALGN)) {289289+ info->prev_sp = 0;290290+ break;291291+ }292292+283293 if (get_user(tmp, (unsigned long *)(info->prev_sp - RP_OFFSET))) 284294 break;285295 info->prev_ip = tmp;