linux/arch/loongarch
Vincent Li 677e6123e3 LoongArch: BPF: Disable trampoline for kernel module function trace
The current LoongArch BPF trampoline implementation is incompatible
with tracing functions in kernel modules. This causes several severe
and user-visible problems:

* The `bpf_selftests/module_attach` test fails consistently.
* Kernel lockup when a BPF program is attached to a module function [1].
* Critical kernel modules like WireGuard experience traffic disruption
  when their functions are traced with fentry [2].

Given the severity and the potential for other unknown side-effects, it
is safest to disable the feature entirely for now. This patch prevents
the BPF subsystem from allowing trampoline attachments to kernel module
functions on LoongArch.

This is a temporary mitigation until the core issues in the trampoline
code for kernel module handling can be identified and fixed.

[root@fedora bpf]# ./test_progs -a module_attach -v
bpf_testmod.ko is already unloaded.
Loading bpf_testmod.ko...
Successfully loaded bpf_testmod.ko.
test_module_attach:PASS:skel_open 0 nsec
test_module_attach:PASS:set_attach_target 0 nsec
test_module_attach:PASS:set_attach_target_explicit 0 nsec
test_module_attach:PASS:skel_load 0 nsec
libbpf: prog 'handle_fentry': failed to attach: -ENOTSUPP
libbpf: prog 'handle_fentry': failed to auto-attach: -ENOTSUPP
test_module_attach:FAIL:skel_attach skeleton attach failed: -524
Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
Successfully unloaded bpf_testmod.ko.

[1]: https://lore.kernel.org/loongarch/CAK3+h2wDmpC-hP4u4pJY8T-yfKyk4yRzpu2LMO+C13FMT58oqQ@mail.gmail.com/
[2]: https://lore.kernel.org/loongarch/CAK3+h2wYcpc+OwdLDUBvg2rF9rvvyc5amfHT-KcFaK93uoELPg@mail.gmail.com/

Cc: stable@vger.kernel.org
Fixes: f9b6b41f0c ("LoongArch: BPF: Add basic bpf trampoline support")
Acked-by: Hengqi Chen <hengqi.chen@gmail.com>
Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2025-11-20 14:42:05 +08:00
..
boot LoongArch: dts: Add eMMC/SDIO controller support to Loongson-2K2000 2025-08-05 19:00:22 +08:00
configs LoongArch changes for v6.18 2025-10-06 12:18:56 -07:00
crypto loongarch/crc32: expose CRC32 functions through lib 2024-12-01 17:23:01 -08:00
include LoongArch: Consolidate CPU names in /proc/cpuinfo 2025-11-20 14:42:05 +08:00
kernel LoongArch: Mask all interrupts during kexec/kdump 2025-11-20 14:42:05 +08:00
kvm LoongArch: KVM: Fix max supported vCPUs set with EIOINTC 2025-11-10 08:37:07 +08:00
lib lib/crc: loongarch: Migrate optimized CRC code into lib/crc/ 2025-06-30 09:31:57 -07:00
mm LoongArch: Consolidate max_pfn & max_low_pfn calculation 2025-11-10 08:37:06 +08:00
net LoongArch: BPF: Disable trampoline for kernel module function trace 2025-11-20 14:42:05 +08:00
pci LoongArch: Don't panic if no valid cache info for PCI 2025-11-20 14:42:05 +08:00
power LoongArch: Save and restore CSR.CNTC for hibernation 2025-05-14 22:17:52 +08:00
vdso LoongArch: vDSO: Remove -nostdlib complier flag 2025-08-05 19:00:22 +08:00
Kbuild LoongArch: Migrate to the generic rule for built-in DTB 2025-01-25 18:51:33 +08:00
Kconfig LoongArch changes for v6.18 2025-10-06 12:18:56 -07:00
Kconfig.debug LoongArch: Only allow OBJTOOL & ORC unwinder if toolchain supports -mthin-add-sub 2024-06-21 10:18:40 +08:00
Makefile rust: kbuild: support -Cjump-tables=n for Rust 1.93.0 2025-11-04 19:11:39 +01:00