linux/arch
Xu Kuohai aada476655 bpf, arm64: Fix bpf trampoline instruction endianness
The sparse tool complains as follows:

arch/arm64/net/bpf_jit_comp.c:1684:16:
	warning: incorrect type in assignment (different base types)
arch/arm64/net/bpf_jit_comp.c:1684:16:
	expected unsigned int [usertype] *branch
arch/arm64/net/bpf_jit_comp.c:1684:16:
	got restricted __le32 [usertype] *
arch/arm64/net/bpf_jit_comp.c:1700:52:
	error: subtraction of different types can't work (different base
	types)
arch/arm64/net/bpf_jit_comp.c:1734:29:
	warning: incorrect type in assignment (different base types)
arch/arm64/net/bpf_jit_comp.c:1734:29:
	expected unsigned int [usertype] *
arch/arm64/net/bpf_jit_comp.c:1734:29:
	got restricted __le32 [usertype] *
arch/arm64/net/bpf_jit_comp.c:1918:52:
	error: subtraction of different types can't work (different base
	types)

This is because the variable branch in function invoke_bpf_prog and the
variable branches in function prepare_trampoline are defined as type
u32 *, which conflicts with ctx->image's type __le32 *, so sparse complains
when assignment or arithmetic operation are performed on these two
variables and ctx->image.

Since arm64 instructions are always little-endian, change the type of
these two variables to __le32 * and call cpu_to_le32() to convert
instruction to little-endian before writing it to memory. This is also
in line with emit() which internally does cpu_to_le32(), too.

Fixes: efc9909fdc ("bpf, arm64: Add bpf trampoline for arm64")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Link: https://lore.kernel.org/bpf/20220808040735.1232002-1-xukuohai@huawei.com
2022-08-10 16:50:57 +02:00
..
alpha genirq: Add and use an irq_data_update_affinity helper 2022-07-07 09:38:04 +01:00
arc jump_label: make initial NOP patching the special case 2022-06-24 09:48:55 +02:00
arm Networking changes for 6.0. 2022-08-03 16:29:08 -07:00
arm64 bpf, arm64: Fix bpf trampoline instruction endianness 2022-08-10 16:50:57 +02:00
csky RCU pull request for v5.20 (or whatever) 2022-08-02 19:12:45 -07:00
hexagon
ia64 EFI efivars sysfs interface removal 2022-08-03 14:41:36 -07:00
loongarch EFI updates for v5.20 2022-08-03 14:38:02 -07:00
m68k flexible-array transformations in UAPI for 6.0-rc1 2022-08-02 19:50:47 -07:00
microblaze
mips flexible-array transformations in UAPI for 6.0-rc1 2022-08-02 19:50:47 -07:00
nios2
openrisc openrisc: unwinder: Fix grammar issue in comment 2022-06-28 17:31:24 +09:00
parisc for-5.20-tag 2022-08-03 14:54:52 -07:00
powerpc iov_iter work, part 1 - isolated cleanups and optimizations. 2022-08-03 13:50:22 -07:00
riscv Networking changes for 6.0. 2022-08-03 16:29:08 -07:00
s390 iov_iter work, part 1 - isolated cleanups and optimizations. 2022-08-03 13:50:22 -07:00
sh ARM: SoC defconfig updates for 6.0 2022-08-02 08:21:58 -07:00
sparc RCU pull request for v5.20 (or whatever) 2022-08-02 19:12:45 -07:00
um Random number generator updates for Linux 6.0-rc1. 2022-08-02 17:31:35 -07:00
x86 Networking changes for 6.0. 2022-08-03 16:29:08 -07:00
xtensa RCU pull request for v5.20 (or whatever) 2022-08-02 19:12:45 -07:00
.gitignore
Kconfig RCU pull request for v5.20 (or whatever) 2022-08-02 19:12:45 -07:00