linux-stable/tools
Petr Pavlu dc4d07ddc4 x86/retpoline,kprobes: Skip optprobe check for indirect jumps with retpolines and IBT
commit 833fd800bf upstream.

The kprobes optimization check can_optimize() calls
insn_is_indirect_jump() to detect indirect jump instructions in
a target function. If any is found, creating an optprobe is disallowed
in the function because the jump could be from a jump table and could
potentially land in the middle of the target optprobe.

With retpolines, insn_is_indirect_jump() additionally looks for calls to
indirect thunks which the compiler potentially used to replace original
jumps. This extra check is however unnecessary because jump tables are
disabled when the kernel is built with retpolines. The same is currently
the case with IBT.

Based on this observation, remove the logic to look for calls to
indirect thunks and skip the check for indirect jumps altogether if the
kernel is built with retpolines or IBT. Remove subsequently the symbols
__indirect_thunk_start and __indirect_thunk_end which are no longer
needed.

Dropping this logic indirectly fixes a problem where the range
[__indirect_thunk_start, __indirect_thunk_end] wrongly included also the
return thunk. It caused that machines which used the return thunk as
a mitigation and didn't have it patched by any alternative ended up not
being able to use optprobes in any regular function.

Fixes: 0b53c374b9 ("x86/retpoline: Use -mfunction-return")
Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Suggested-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/20230711091952.27944-3-petr.pavlu@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-23 17:32:41 +02:00
..
accounting delayacct: track delays from IRQ/SOFTIRQ 2023-04-18 16:39:34 -07:00
arch x86/bugs: Increase the x86 bugs vector size to two u32s 2023-08-08 20:04:51 +02:00
bootconfig
bpf tools/resolve_btfids: Fix setting HOSTCFLAGS 2023-07-19 16:35:26 +02:00
build tools build: Add a feature test for scandirat(), that is not implemented so far in musl and uclibc 2023-04-04 13:18:17 -03:00
certs
cgroup
counter
debugging
edid
firewire
firmware
gpio tools: gpio: fix debounce_period_us output of lsgpio 2023-05-11 10:56:24 +02:00
hv
iio
include tools/nolibc: ensure stack protector guard is never zero 2023-07-27 08:56:48 +02:00
io_uring
kvm/kvm_stat tools/kvm_stat: use canonical ftrace path 2023-03-29 06:52:08 -04:00
laptop
leds
lib libbpf: fix offsetof() and container_of() to work with CO-RE 2023-07-19 16:35:23 +02:00
memory-model LKMM scripting updates for v6.4 2023-04-24 12:02:25 -07:00
mm slab changes for 6.4 2023-04-25 13:00:41 -07:00
net/ynl tools: ynl-gen: fix enum index in _decode_enum(..) 2023-08-03 10:25:53 +02:00
objtool x86/retpoline,kprobes: Fix position of thunk sections with CONFIG_LTO_CLANG 2023-08-23 17:32:41 +02:00
pci
pcmcia
perf x86/retpoline,kprobes: Skip optprobe check for indirect jumps with retpolines and IBT 2023-08-23 17:32:41 +02:00
power cpupower: Make TSC read per CPU for Mperf monitor 2023-05-08 10:46:49 -06:00
rcu
scripts sh updates for v6.4 2023-04-27 17:41:23 -07:00
spi
testing nexthop: Fix infinite nexthop bucket dump when using maximum nexthop ID 2023-08-16 18:32:28 +02:00
thermal
time
tracing rtla/hwnoise: Reduce runtime to 75% 2023-07-19 16:36:36 +02:00
usb
verification rv: Fix addition on an uninitialized variable 'run' 2023-04-25 17:02:13 -04:00
virtio tools/virtio: fix build break for aarch64 2023-07-19 16:36:41 +02:00
wmi
Makefile tools/Makefile: do missed s/vm/mm/ 2023-04-18 14:22:12 -07:00