Re: [PATCH -tip v8 08/13] arm: kprobes: Make a space for regs->ARM_pc at kretprobe_trampoline

Masami Hiramatsu
2021-07-05T14:40:14Z

On Mon, 5 Jul 2021 10:04:41 +0200
Ingo Molnar <mingo@kernel.org> wrote:

>
> * Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
> > Change kretprobe_trampoline to make a space for regs->ARM_pc so that
> > kretprobe_trampoline_handler can call instruction_pointer_set()
> > safely.
>
> The idiom is "make space", but in any case, what does this mean?

Since arm's kretprobe_trampoline() saves partial pt_regs, regs->ARM_pc
is not accessible (it points the caller function's stack frame).
Therefore, this extends the stack frame for storing regs->ARM_pc.

>
> Was the stack frame set up in kretprobe_trampoline() and calling
> trampoline_handler() buggy?
>
> If yes, then explain the bad effects of the bug, and make all of this clear
> in the title & changelog.

This is actually buggy from the specification viewpoint. And if
the kretprobe handler sets the instruction pointer, it must be
ignored, but in reallty, it breaks the stack frame (this does
not happen in the ftrace/perf dynamic events, but a custom kretprobe
kernel module can do this.)

Thank you,

>
> Thanks,
>
> Ingo

--
Masami Hiramatsu <mhiramat@kernel.org>