]> git.baikalelectronics.ru Git - kernel.git/commit
x86/kprobes: Fix optprobe optimization check with CONFIG_RETHUNK
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Mon, 19 Dec 2022 14:35:19 +0000 (23:35 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jan 2023 10:11:48 +0000 (11:11 +0100)
commit265887553b6f420a9f9c9f58b01867105c27f2ea
treeadca5b913914847160b10687e988622a1281da22
parentc812c0efafdb8adb9c92b31294e5bb110fcb8fa7
x86/kprobes: Fix optprobe optimization check with CONFIG_RETHUNK

commit 6ce977d624eba18d178f2eb6f1a113a9b671d61f upstream.

Since the CONFIG_RETHUNK and CONFIG_SLS will use INT3 for stopping
speculative execution after function return, kprobe jump optimization
always fails on the functions with such INT3 inside the function body.
(It already checks the INT3 padding between functions, but not inside
 the function)

To avoid this issue, as same as kprobes, check whether the INT3 comes
from kgdb or not, and if so, stop decoding and make it fail. The other
INT3 will come from CONFIG_RETHUNK/CONFIG_SLS and those can be
treated as a one-byte instruction.

Fixes: 436159b63b3d ("x86: Add straight-line-speculation mitigation")
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/167146051929.1374301.7419382929328081706.stgit@devnote3
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/kprobes/opt.c