TencentOS-kernel/arch/x86
Alexei Starovoitov 777470d8fa bpf: Fix trampoline generation for fmod_ret programs
[upstream commit 13fac1d851e09109096b5862bf37c3da6908fb48]

fmod_ret progs are emitted as:

start = __bpf_prog_enter();
call fmod_ret
*(u64 *)(rbp - 8) = rax
__bpf_prog_exit(, start);
test eax, eax
jne do_fexit

That 'test eax, eax' is working by accident. The compiler is free to use rax
inside __bpf_prog_exit() or inside functions that __bpf_prog_exit() is calling.
Which caused "test_progs -t modify_return" to sporadically fail depending on
compiler version and kconfig. Fix it by using 'cmp [rbp - 8], 0' instead of
'test eax, eax'.

Fixes: ae24082331d9 ("bpf: Introduce BPF_MODIFY_RETURN")
Reported-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: KP Singh <kpsingh@google.com>
Link: https://lore.kernel.org/bpf/20200311003906.3643037-1-ast@kernel.org
2022-06-21 10:27:07 +08:00
..
boot x86/asm: Replace __force_order with a memory clobber 2021-03-16 16:39:12 +08:00
configs vgacon: remove software scrollback support 2021-03-16 16:36:07 +08:00
crypto crypto: x86/aes-ni-xts - use direct calls to and 4-way stride 2021-04-12 12:53:14 +08:00
entry sli/cpu: introduce longsys check 2021-10-29 06:51:52 +00:00
events perf/amd/uncore: Add support for Family 19h L3 PMU 2021-09-23 19:21:43 +08:00
hyperv x86/hyperv: check cpu mask after interrupt has been disabled 2021-04-12 12:51:21 +08:00
ia32 Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
include x86/elf: Move vmcore_elf_check_arch_cross to arch/x86/include/asm/elf.h 2022-06-06 13:50:36 +08:00
kernel x86/mpparse, kexec: switch apic driver early if x2apic is pre-enabled 2022-06-09 10:01:21 +08:00
kvm x86/process/64: Make save_fsgs_for_kvm() ready for FSGSBASE 2021-08-17 06:29:11 +00:00
lib x86/cpufeatures: Add support for fast short REP; MOVSB 2021-11-30 15:41:45 +08:00
math-emu x86: math-emu: Fix up 'cmp' insn for clang ias 2021-03-16 16:32:34 +08:00
mm uaccess: Add strict non-pagefault kernel-space read function 2022-06-21 10:27:04 +08:00
net bpf: Fix trampoline generation for fmod_ret programs 2022-06-21 10:27:07 +08:00
oprofile Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
pci x86/PCI: Fix intel_mid_pci.c build error when ACPI is not enabled 2021-03-16 16:39:28 +08:00
platform efi/x86: Free efi_pgd with free_pages() 2021-03-16 16:41:24 +08:00
power x86/asm/32: Add ENDs to some functions and relabel with SYM_CODE_* 2021-04-12 12:51:15 +08:00
purgatory x86/purgatory: Disable various profiling and sanitizing options 2021-03-16 16:30:08 +08:00
ras Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
realmode x86/asm/32: Add ENDs to some functions and relabel with SYM_CODE_* 2021-04-12 12:51:15 +08:00
tools x86/build: Treat R_386_PLT32 relocation as R_386_PC32 2021-04-12 12:52:46 +08:00
um Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
video Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
xen Xen/gnttab: handle p2m update errors on a per-slot basis 2021-04-12 12:52:49 +08:00
.gitignore Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Kbuild Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Kconfig x86, arm64: Add ARCH_WANT_RESERVE_CRASH_KERNEL config 2022-06-06 13:52:03 +08:00
Kconfig.cpu x86/intel: Initialize IA32_FEAT_CTL MSR at boot 2021-07-12 08:56:46 +00:00
Kconfig.debug Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Makefile x86/build: Propagate $(CLANG_FLAGS) to $(REALMODE_FLAGS) 2021-05-20 16:07:24 +08:00
Makefile.um Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Makefile_32.cpu Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00