Re: [RFC][PATCH] x86: ptrace: Add function argument access API

From: Steven Rostedt
Date: Wed Oct 17 2018 - 22:34:53 EST


On Mon, 15 Oct 2018 23:56:46 +0900
Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:

> On Fri, 12 Oct 2018 15:54:39 -0400
> Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> > On Fri, 12 Oct 2018 11:21:28 -0700
> > Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:
> >
> > > On Fri, Oct 12, 2018 at 9:26 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> > > >
> > > >
> > > > Anyone have any issues with this patch?
> > > >
> > >
> > > I'm conceptually okay with it. That being said,
> > > regs_within_kernel_stack(), which you're indirectly using, is
> > > off-by-a-few. And updating it to use probe_kernel_read() might be
> > > nice for robustness.
> > >
> >
> > Something like this?
> >
> > -- Steve
> >
> > From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>
> > Date: Fri, 12 Oct 2018 15:44:20 -0400
> > Subject: [PATCH] x86: ptrace.h: Add regs_get_kernel_stack_nth_safe() function
> >
> > Andy had some concerns about using regs_get_kernel_stack_nth() in a new
> > function regs_get_kernel_argument() as if there's any error in the stack
> > code, it could cause a bad memory access. Instead, add a new function called
> > regs_get_kernel_stack_nth_safe() that does a probe_kernel_read() on the
> > stack address to be extra careful in accessing the memory. To share the
> > code, regs_get_kernel_stack_nth_addr() was added to just return the stack
> > address (or NULL if not on the stack), that both regs_get_kernel_stack_nth()
> > and the _safe() version can use.
>
> This patch looks good to me.
> But if the concern is real, all regs_get_kernel_stack_nth() user must move
> onto _safe() version, at least all tracers code.
>
> Reviewed-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
>

Hi Masami,

Can you review my v2 version which implements what you suggest.

Thanks,

-- Steve