]> git.baikalelectronics.ru Git - kernel.git/commit
x86/kprobes: Fix optprobe to detect INT3 padding correctly
authorMasami Hiramatsu <mhiramat@kernel.org>
Fri, 11 Dec 2020 07:04:17 +0000 (16:04 +0900)
committerBorislav Petkov <bp@suse.de>
Sat, 12 Dec 2020 14:25:17 +0000 (15:25 +0100)
commitc1af6a5be905daf4563abd9df3caa4c8bb70fb0d
treeca19541841b50372bb92d9ad2e3043a927d943f2
parent77e3c26ccda872afa36be3117667ba4d71fff346
x86/kprobes: Fix optprobe to detect INT3 padding correctly

Commit

  0c0f4d07e7b0 ("x86/vmlinux: Use INT3 instead of NOP for linker fill bytes")

changed the padding bytes between functions from NOP to INT3. However,
when optprobe decodes a target function it finds INT3 and gives up the
jump optimization.

Instead of giving up any INT3 detection, check whether the rest of the
bytes to the end of the function are INT3. If all of them are INT3,
those come from the linker. In that case, continue the optprobe jump
optimization.

 [ bp: Massage commit message. ]

Fixes: 0c0f4d07e7b0 ("x86/vmlinux: Use INT3 instead of NOP for linker fill bytes")
Reported-by: Adam Zabrocki <pi3@pi3.com.pl>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/160767025681.3880685.16021570341428835411.stgit@devnote2
arch/x86/kernel/kprobes/opt.c