Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions arch/riscv/kernel/stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@
extern asmlinkage void handle_exception(void);
extern unsigned long ret_from_exception_end;

static inline int fp_is_valid(unsigned long fp, unsigned long sp)
static inline int fp_is_valid(unsigned long fp, unsigned long sp,
struct task_struct *task)
{
unsigned long low, high;

if (!task)
task = current;

low = sp + sizeof(struct stackframe);
high = ALIGN(sp, THREAD_SIZE);
high = (unsigned long)task_stack_page(task) + THREAD_SIZE;

return !(fp < low || fp > high || fp & 0x07);
}
Expand Down Expand Up @@ -74,13 +78,13 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
if (unlikely(!__kernel_text_address(pc) || (level++ >= 0 && !fn(arg, pc))))
break;

if (unlikely(!fp_is_valid(fp, sp)))
if (unlikely(!fp_is_valid(fp, sp, task)))
break;

/* Unwind stack frame */
frame = (struct stackframe *)fp - 1;
sp = fp;
if (regs && (regs->epc == pc) && fp_is_valid(frame->ra, sp)) {
if (regs && (regs->epc == pc) && fp_is_valid(frame->ra, sp, task)) {
/* We hit function where ra is not saved on the stack */
fp = frame->ra;
pc = regs->ra;
Expand Down
Loading