TencentOS-kernel/arch
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
..
alpha net: retrieve netns cookie via getsocketopt 2021-12-30 14:50:11 +08:00
arc arc: kernel: Return -EFAULT if copy_to_user() fails 2021-05-20 16:07:08 +08:00
arm bpf: Introduce BPF nospec instruction for mitigating Spectre v4 2022-06-21 10:27:02 +08:00
arm64 bpf: Introduce BPF nospec instruction for mitigating Spectre v4 2022-06-21 10:27:02 +08:00
c6x Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
csky csky: change a Kconfig symbol name to fix e1000 build error 2021-05-20 16:07:15 +08:00
h8300 h8300: fix PREEMPTION build, TI_PRE_COUNT undefined 2021-04-12 12:52:05 +08:00
hexagon hexagon: define ioremap_uc 2021-03-16 16:27:29 +08:00
ia64 ia64: fix discontig.c section mismatches 2021-05-20 16:07:15 +08:00
m68k m68k: mvme147,mvme16x: Don't wipe PCC timer config bits 2021-05-20 16:07:48 +08:00
microblaze Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
mips bpf: Introduce BPF nospec instruction for mitigating Spectre v4 2022-06-21 10:27:02 +08:00
nds32 nds32: flush_dcache_page: use page_mapping_file to avoid races with swapoff 2021-05-20 16:06:56 +08:00
nios2 Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
openrisc openrisc: Fix issue with get_user for 64-bit values 2021-03-16 16:39:36 +08:00
parisc net: retrieve netns cookie via getsocketopt 2021-12-30 14:50:11 +08:00
powerpc bpf: Introduce BPF nospec instruction for mitigating Spectre v4 2022-06-21 10:27:02 +08:00
riscv bpf: Introduce BPF nospec instruction for mitigating Spectre v4 2022-06-21 10:27:02 +08:00
s390 bpf: Introduce BPF nospec instruction for mitigating Spectre v4 2022-06-21 10:27:02 +08:00
sh sh: dma: fix kconfig dependency for G2_DMA 2021-04-12 12:51:39 +08:00
sparc bpf: Introduce BPF nospec instruction for mitigating Spectre v4 2022-06-21 10:27:02 +08:00
um um: mm: check more comprehensively for stub changes 2021-04-12 12:52:40 +08:00
unicore32 Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
x86 bpf: Fix trampoline generation for fmod_ret programs 2022-06-21 10:27:07 +08:00
xtensa xtensa: move coprocessor_flush to the .text section 2021-05-20 16:06: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
Kconfig x86, arm64: Add ARCH_WANT_RESERVE_CRASH_KERNEL config 2022-06-06 13:52:03 +08:00