[RFC PATCH 3/3] arm64: stacktrace: Implement reliable stacktrace
Miroslav Benes
mbenes at suse.cz
Thu Oct 15 09:33:44 EDT 2020
On Mon, 12 Oct 2020, Mark Brown wrote:
> +int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry,
> + void *cookie, struct task_struct *task)
> +{
> + struct stackframe frame;
> +
> + if (task == current)
> + start_backtrace(&frame,
> + (unsigned long)__builtin_frame_address(0),
> + (unsigned long)arch_stack_walk_reliable);
> + else
> + start_backtrace(&frame, thread_saved_fp(task),
> + thread_saved_pc(task));
> +
> + while (1) {
> + int ret;
> +
> +#ifdef CONFIG_KPROBES
> + /*
> + * Mark stacktraces with kretprobed functions on them
> + * as unreliable.
> + */
> + if (frame.pc == (unsigned long)kretprobe_trampoline)
> + return -EINVAL;
> +#endif
I think it would be nice to check if frame.pc is a valid text address here
before it is consumed next.
> + if (!consume_entry(cookie, frame.pc))
> + return -EINVAL;
> + ret = unwind_frame(task, &frame);
> + if (ret == -ENOENT)
> + return 0;
> + if (ret < 0)
> + return ret;
> + }
> +}
Miroslav
More information about the linux-arm-kernel
mailing list