sst-linux/arch
Hengqi Chen e9ccb262b3 LoongArch: BPF: Fix off-by-one error in build_prologue()
commit 7e2586991e36663c9bc48c828b83eab180ad30a9 upstream.

Vincent reported that running BPF progs with tailcalls on LoongArch
causes kernel hard lockup. Debugging the issues shows that the JITed
image missing a jirl instruction at the end of the epilogue.

There are two passes in JIT compiling, the first pass set the flags and
the second pass generates JIT code based on those flags. With BPF progs
mixing bpf2bpf and tailcalls, build_prologue() generates N insns in the
first pass and then generates N+1 insns in the second pass. This makes
epilogue_offset off by one and we will jump to some unexpected insn and
cause lockup. Fix this by inserting a nop insn.

Cc: stable@vger.kernel.org
Fixes: 5dc615520c ("LoongArch: Add BPF JIT support")
Fixes: bb035ef0cc91 ("LoongArch: BPF: Support mixing bpf2bpf and tailcalls")
Reported-by: Vincent Li <vincent.mc.li@gmail.com>
Tested-by: Vincent Li <vincent.mc.li@gmail.com>
Closes: https://lore.kernel.org/loongarch/CAK3+h2w6WESdBN3UCr3WKHByD7D6Q_Ve1EDAjotVrnx6Or_c8g@mail.gmail.com/
Closes: https://lore.kernel.org/bpf/CAK3+h2woEjG_N=-XzqEGaAeCmgu2eTCUc7p6bP4u8Q+DFHm-7g@mail.gmail.com/
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-10 14:33:41 +02:00
..
alpha alpha/elf: Fix misc/setarch test of util-linux by removing 32bit support 2025-03-28 21:58:51 +01:00
arc ARC: build: Try to guess GCC variant of cross compiler 2025-01-09 13:30:05 +01:00
arm ARM: dts: imx6qdl-apalis: Fix poweroff on Apalis iMX6 2025-04-07 10:05:46 +02:00
arm64 arm64: dts: rockchip: fix u2phy1_host status for NanoPi R4S 2025-03-28 21:59:02 +01:00
csky mm: remove kern_addr_valid() completely 2024-11-08 16:26:39 +01:00
hexagon hexagon: Fix unbalanced spinlock in die() 2025-02-21 13:49:25 +01:00
ia64 mm: remove kern_addr_valid() completely 2024-11-08 16:26:39 +01:00
loongarch LoongArch: BPF: Fix off-by-one error in build_prologue() 2025-04-10 14:33:41 +02:00
m68k m68k: vga: Fix I/O defines 2025-02-21 13:49:38 +01:00
microblaze microblaze: Export xmb_manager functions 2024-12-14 19:53:20 +01:00
mips ptrace: Introduce exception_ip arch hook 2025-03-07 16:56:51 +01:00
nios2 mm: remove kern_addr_valid() completely 2024-11-08 16:26:39 +01:00
openrisc mm: remove kern_addr_valid() completely 2024-11-08 16:26:39 +01:00
parisc parisc/ftrace: Fix function graph tracing disablement 2024-12-14 19:54:02 +01:00
powerpc spufs: fix a leak in spufs_create_context() 2025-04-10 14:33:40 +02:00
riscv riscv: ftrace: Add parentheses in macro definitions of make_call_t0 and make_call_ra 2025-04-10 14:33:40 +02:00
s390 s390/traps: Fix test_monitor_call() inline assembly 2025-03-13 12:53:15 +01:00
sh sh: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK 2024-12-14 19:54:03 +01:00
sparc mm: remove kern_addr_valid() completely 2024-11-08 16:26:39 +01:00
um um: remove copy_from_kernel_nofault_allowed 2025-04-10 14:33:36 +02:00
x86 x86/sgx: Warn explicitly if X86_FEATURE_SGX_LC is not enabled 2025-04-10 14:33:39 +02:00
xtensa mm: remove kern_addr_valid() completely 2024-11-08 16:26:39 +01:00
.gitignore
Kconfig Revert "mm: mmap: allow for the maximum number of bits for randomizing mmap_base by default" 2024-06-27 13:46:24 +02:00