linux-stable/tools
Josh Poimboeuf 34de4fe7d1 objtool: Fix return thunk patching in retpolines
With CONFIG_RETHUNK enabled, the compiler replaces every RET with a tail
call to a return thunk ('JMP __x86_return_thunk').  Objtool annotates
all such return sites so they can be patched during boot by
apply_returns().

The implementation of __x86_return_thunk() is just a bare RET.  It's
only meant to be used temporarily until apply_returns() patches all
return sites with either a JMP to another return thunk or an actual RET.

Removing the .text..__x86.return_thunk section would break objtool's
detection of return sites in retpolines.  Since retpolines and return
thunks would land in the same section, the compiler no longer uses
relocations for the intra-section jumps between the retpolines and the
return thunk, causing objtool to overlook them.

As a result, none of the retpolines' return sites would get patched.
Each one stays at 'JMP __x86_return_thunk', effectively a bare RET.

Fix it by teaching objtool to detect when a non-relocated jump target is
a return thunk (or retpoline).

  [ bp: Massage the commit message now that the offending commit
    removing the .text..__x86.return_thunk section has been zapped.
    Still keep the objtool change here as it makes objtool more robust
    wrt handling such intra-TU jumps without relocations, should some
    toolchain and/or config generate them in the future. ]

Reported-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231012024737.eg5phclogp67ik6x@treble
2023-10-20 12:51:41 +02:00
..
accounting
arch tools arch x86: Sync the msr-index.h copy with the kernel sources 2023-09-13 08:53:37 -03:00
bootconfig
bpf bpftool: Fix build warnings with -Wtype-limits 2023-08-30 08:39:00 +02:00
build perf tools changes for v6.6: 2023-09-09 20:06:17 -07:00
certs
cgroup iocost_monitor: improve it by adding iocg wait_ms 2023-08-08 15:43:03 -06:00
counter
crypto/ccp
debugging
edid
firewire
firmware
gpio
hv hv/hv_kvp_daemon:Support for keyfile based connection profile 2023-10-10 03:42:29 +00:00
iio tools: iio: iio_generic_buffer: Fix some integer type and calculation 2023-07-29 15:59:20 +01:00
include perf tools fixes for v6.6: 1st batch 2023-09-26 08:41:26 -07:00
kvm/kvm_stat
laptop
leds
lib perf tools changes for v6.6: 2023-09-09 20:06:17 -07:00
memory-model
mm tools/mm: fix undefined reference to pthread_once 2023-09-05 10:13:45 -07:00
net/ynl tools/net/ynl: Add support for create flags 2023-08-27 17:17:10 -07:00
objtool objtool: Fix return thunk patching in retpolines 2023-10-20 12:51:41 +02:00
pci
pcmcia
perf perf jevent: fix core dump on software events on s390 2023-09-17 15:51:57 -07:00
power More power management updates for 6.6-rc1 2023-09-04 15:21:55 -07:00
rcu
scripts tools build: Add 3-component logical version comparators 2023-08-03 16:59:40 -03:00
spi
testing RISC-V Fixes for 6.6-rc6 2023-10-13 09:17:48 -07:00
thermal
time
tracing rtla/timerlat: Do not stop user-space if a cpu is offline 2023-09-22 14:43:46 +02:00
usb
verification
virtio
wmi
workqueue workqueue: Implement non-strict affinity scope for unbound workqueues 2023-08-07 15:57:25 -10:00
Makefile