linux-stable/tools/perf
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
..
Documentation perf lock contention: Update default map size to 16384 2023-04-06 21:52:27 -03:00
arch perf pmu arm64: Fix reading the PMU cpu slots in sysfs 2023-08-11 12:14:08 +02:00
bench tools headers: Update the copy of x86's mem{cpy,set}_64.S used in 'perf bench' 2023-05-17 10:42:19 -03:00
dlfilters
examples/bpf
include/perf
jvmti
pmu-events perf metric: JSON flag to not group events if gathering a metric group 2023-05-10 12:35:02 -03:00
python
scripts perf script: Add new parameter in kfree_skb tracepoint to the python scripts using it 2023-05-02 08:36:14 -03:00
tests perf test uprobe_from_different_cu: Skip if there is no gcc 2023-08-11 12:14:11 +02:00
trace tools headers UAPI: Sync arch prctl headers with the kernel sources 2023-05-17 11:23:43 -03:00
ui perf dso: Fix use before NULL check introduced by map__dso() introduction 2023-04-19 10:51:48 -03:00
util x86/retpoline,kprobes: Skip optprobe check for indirect jumps with retpolines and IBT 2023-08-23 17:32:41 +02:00
.gitignore perf jevents: Run metric_test.py at compile-time 2023-02-03 17:11:39 -03:00
Build perf script: Fix Python support when no libtraceevent 2023-03-15 10:27:07 -03:00
CREDITS
MANIFEST
Makefile
Makefile.config perf build: Fix library not found error when using CSLIBS 2023-07-27 08:56:54 +02:00
Makefile.perf perf bpf: Do not use llvm-strip on BPF binary 2023-05-26 15:30:23 -03:00
builtin-annotate.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-bench.c perf bench: Add missing setlocale() call to allow usage of %'d style formatting 2023-07-19 16:36:12 +02:00
builtin-buildid-cache.c
builtin-buildid-list.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-c2c.c perf c2c: Use zfree() to reduce chances of use after free 2023-04-12 09:55:10 -03:00
builtin-config.c
builtin-daemon.c perf daemon: Use zfree() to reduce chances of use after free 2023-04-12 09:52:29 -03:00
builtin-data.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-diff.c perf util: Move perf_guest/host declarations 2023-04-10 19:22:05 -03:00
builtin-evlist.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-ftrace.c perf ftrace latency: Remove unnecessary "--" from --use-nsec option 2023-05-26 10:23:39 -03:00
builtin-help.c perf usage: Move usage strings 2023-04-10 19:20:53 -03:00
builtin-inject.c perf dso: Add dso__filename_with_chroot() to reduce number of accesses to dso->nsinfo members 2023-04-17 18:47:55 -03:00
builtin-kallsyms.c perf map: Add helper for ->map_ip() and ->unmap_ip() 2023-04-06 22:10:17 -03:00
builtin-kmem.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-kvm.c perf evsel: Introduce evsel__name_is() method to check if the evsel name is equal to a given string 2023-04-24 14:28:11 -03:00
builtin-kwork.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-list.c perf list: Use zfree() to reduce chances of use after free 2023-04-12 09:55:44 -03:00
builtin-lock.c Revert "perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL" 2023-05-06 18:07:37 -03:00
builtin-mem.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-probe.c tools: Rename __fallthrough to fallthrough 2023-04-06 21:41:00 -03:00
builtin-record.c Revert "perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL" 2023-05-06 18:07:37 -03:00
builtin-report.c perf map: Add accessors for ->pgoff and ->reloc 2023-04-06 22:12:40 -03:00
builtin-sched.c perf sched: Fix sched latency analysis incorrection when using 'sched:sched_wakeup' 2023-04-12 19:30:39 -03:00
builtin-script.c perf script: Fix allocation of evsel->priv related to per-event dump files 2023-07-19 16:36:13 +02:00
builtin-stat.c perf stat: Reset aggr stats for each run 2023-07-19 16:36:15 +02:00
builtin-timechart.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-top.c perf map: Add set_ methods for map->{start,end,pgoff,pgoff,reloc,erange_warned,dso,map_ip,unmap_ip,priv} 2023-04-19 12:54:41 -03:00
builtin-trace.c perf trace: Use zfree() to reduce chances of use after free 2023-04-12 09:54:32 -03:00
builtin-version.c Revert "perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL" 2023-05-06 18:07:37 -03:00
builtin.h perf usage: Move usage strings 2023-04-10 19:20:53 -03:00
check-headers.sh Disable building BPF based features by default for v6.4. 2023-05-07 11:32:18 -07:00
command-list.txt
design.txt
perf-archive.sh
perf-completion.sh perf tools: Fix auto-complete on aarch64 2023-02-08 10:38:10 -03:00
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
perf.h perf util: Move perf_guest/host declarations 2023-04-10 19:22:05 -03:00