linux-stable/arch/x86
Alexei Starovoitov e21d2b9235 bpf: Fix fexit trampoline.
[ Upstream commit e21aa34178 ]

The fexit/fmod_ret programs can be attached to kernel functions that can sleep.
The synchronize_rcu_tasks() will not wait for such tasks to complete.
In such case the trampoline image will be freed and when the task
wakes up the return IP will point to freed memory causing the crash.
Solve this by adding percpu_ref_get/put for the duration of trampoline
and separate trampoline vs its image life times.
The "half page" optimization has to be removed, since
first_half->second_half->first_half transition cannot be guaranteed to
complete in deterministic time. Every trampoline update becomes a new image.
The image with fmod_ret or fexit progs will be freed via percpu_ref_kill and
call_rcu_tasks. Together they will wait for the original function and
trampoline asm to complete. The trampoline is patched from nop to jmp to skip
fexit progs. They are freed independently from the trampoline. The image with
fentry progs only will be freed via call_rcu_tasks_trace+call_rcu_tasks which
will wait for both sleepable and non-sleepable progs to complete.

Fixes: fec56f5890 ("bpf: Introduce BPF trampoline")
Reported-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Paul E. McKenney <paulmck@kernel.org>  # for RCU
Link: https://lore.kernel.org/bpf/20210316210007.38949-1-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-04-07 15:00:03 +02:00
..
boot A set of fixes for x86: 2020-12-06 11:22:39 -08:00
configs * A defconfig fix, from Daniel Díaz. 2020-09-20 15:06:43 -07:00
crypto crypto: x86/aes-ni-xts - use direct calls to and 4-way stride 2021-03-20 10:43:43 +01:00
entry x86/entry: Fix entry/exit mismatch on failed fast 32-bit syscalls 2021-03-17 17:06:36 +01:00
events perf/x86/intel: Fix unchecked MSR access error caused by VLBR_EVENT 2021-03-25 09:04:16 +01:00
hyperv x86/hyperv: Fix kexec panic/hang issues 2021-01-27 11:54:57 +01:00
ia32 x86: remove address space overrides using set_fs() 2020-09-08 22:21:36 -04:00
include Revert "xen: fix p2m size in dom0 for disabled memory hotplug case" 2021-03-30 14:32:08 +02:00
kernel x86/apic/of: Fix CPU devicetree-node lookups 2021-03-25 09:04:18 +01:00
kvm KVM: x86: Protect userspace MSR filter with SRCU, and set atomically-ish 2021-03-30 14:31:53 +02:00
lib x86/sev-es: Use __copy_from_user_inatomic() 2021-03-17 17:06:36 +01:00
math-emu treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
mm x86/mem_encrypt: Correct physical address calculation in __set_clr_pte_enc() 2021-03-30 14:32:07 +02:00
net bpf: Fix fexit trampoline. 2021-04-07 15:00:03 +02:00
oprofile
pci x86/pci: Create PCI/MSI irqdomain after x86_init.pci.arch_init() 2021-02-17 11:02:28 +01:00
platform x86/efi: Remove EFI PGD build time checks 2021-02-17 11:02:24 +01:00
power Kbuild updates for v5.9 2020-08-09 14:10:26 -07:00
purgatory treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
ras
realmode x86/head/64: Don't call verify_cpu() on starting APs 2020-09-09 11:33:20 +02:00
tools x86/build: Treat R_386_PLT32 relocation as R_386_PC32 2021-03-07 12:34:04 +01:00
um arch/um: partially revert the conversion to __section() macro 2020-10-26 15:39:37 -07:00
video
xen Revert "xen: fix p2m size in dom0 for disabled memory hotplug case" 2021-03-30 14:32:08 +02:00
.gitignore
Kbuild
Kconfig fanotify: Fix sys_fanotify_mark() on native x86-32 2021-01-17 14:16:59 +01:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug x86, powerpc: Rename memcpy_mcsafe() to copy_mc_to_{user, kernel}() 2020-10-06 11:18:04 +02:00
Makefile x86/build: Disable CET instrumentation in the kernel for 32-bit too 2021-02-17 11:02:27 +01:00
Makefile.um
Makefile_32.cpu