Re: [PATCH 1/2] x86/kprobes: Fix kprobes instruction boudary check with CONFIG_RETHUNK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 7 Sep 2022 14:59:41 +0200
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> On Wed, Sep 07, 2022 at 09:55:21AM +0900, Masami Hiramatsu (Google) wrote:
> > From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
> > 
> > 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@xxxxxxxxxx>
> > Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > 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@xxxxxxxxxx>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux