lkml.org 
[lkml]   [2022]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] x86/kprobes: Fix kprobes instruction boudary check with CONFIG_RETHUNK
On Wed, 7 Sep 2022 14:59:41 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> On Wed, Sep 07, 2022 at 09:55:21AM +0900, Masami Hiramatsu (Google) wrote:
> > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> >
> > Since the CONFIG_RETHUNK and CONFIG_SLS will use INT3 for padding after
> > RET instruction, kprobes always failes to check the probed instruction
> > boundary by decoding the function body if the probed address is after
> > such paddings (Note that some conditional code blocks will be placed
> > after RET instruction, if compiler decides it is not on the hot path.)
> > This is because kprobes expects someone (e.g. kgdb) puts the INT3 as
> > a software breakpoint and it will replace the original instruction.
> > But There are INT3 just for padding in the function, it doesn't need
> > to recover the original instruction.
> >
> > To avoid this issue, if kprobe finds an INT3, it gets the address of
> > next non-INT3 byte, and search a branch which jumps to the address.
> > If there is the branch, these INT3 will be for padding, so it can be
> > skipped.
> >
> > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > Suggested-by: Peter Zijlstra <peterz@infradead.org>
> > Fixes: 15e67227c49a ("x86: Undo return-thunk damage")
>
> I take objection with this Fixes tag.. if anything it should be the SLS
> commit that predates this.
>
> e463a09af2f0 ("x86: Add straight-line-speculation mitigation")

Thanks, I'll change to it.


--
Masami Hiramatsu (Google) <mhiramat@kernel.org>

\
 
 \ /
  Last update: 2022-09-07 15:54    [W:0.242 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site