android_kernel_motorola_sm6375/kernel/bpf
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Daniel Borkmann adfbc2440a bpf: Fix bpf_strtol and bpf_strtoul helpers for 32bit
[ Upstream commit cfe69c50b05510b24e26ccb427c7cc70beafd6c1 ]

The bpf_strtol() and bpf_strtoul() helpers are currently broken on 32bit:

The argument type ARG_PTR_TO_LONG is BPF-side "long", not kernel-side "long"
and therefore always considered fixed 64bit no matter if 64 or 32bit underlying
architecture.

This contract breaks in case of the two mentioned helpers since their BPF_CALL
definition for the helpers was added with {unsigned,}long *res. Meaning, the
transition from BPF-side "long" (BPF program) to kernel-side "long" (BPF helper)
breaks here.

Both helpers call __bpf_strtoll() with "long long" correctly, but later assigning
the result into 32-bit "*(long *)" on 32bit architectures. From a BPF program
point of view, this means upper bits will be seen as uninitialised.

Therefore, fix both BPF_CALL signatures to {s,u}64 types to fix this situation.

Now, changing also uapi/bpf.h helper documentation which generates bpf_helper_defs.h
for BPF programs is tricky: Changing signatures there to __{s,u}64 would trigger
compiler warnings (incompatible pointer types passing 'long *' to parameter of type
'__s64 *' (aka 'long long *')) for existing BPF programs.

Leaving the signatures as-is would be fine as from BPF program point of view it is
still BPF-side "long" and thus equivalent to __{s,u}64 on 64 or 32bit underlying
architectures.

Note that bpf_strtol() and bpf_strtoul() are the only helpers with this issue.

Fixes: d7a4cb9b67 ("bpf: Introduce bpf_strtol and bpf_strtoul helpers")
Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/481fcec8-c12c-9abb-8ecb-76c71c009959@iogearbox.net
Link: https://lore.kernel.org/r/20240913191754.13290-1-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-08 16:20:31 +01:00
..
arraymap.c bpf: Add map and need_defer parameters to .map_fd_put_ptr() 2024-02-23 08:24:57 +01:00
bpf_lru_list.c bpf: Address KCSAN report on bpf_lru_list 2023-07-27 08:37:42 +02:00
bpf_lru_list.h bpf: Address KCSAN report on bpf_lru_list 2023-07-27 08:37:42 +02:00
btf.c
cgroup.c bpf: Don't EFAULT for getsockopt with optval=NULL 2023-05-17 11:35:44 +02:00
core.c
cpumap.c bpf: report RCU QS in cpumap kthread 2024-03-26 18:22:25 -04:00
devmap.c bpf: Fix DEVMAP_HASH overflow check on 32-bit arches 2024-11-08 16:20:26 +01:00
disasm.c
disasm.h
hashtab.c bpf: Fix hashtab overflow check on 32-bit arches 2024-03-26 18:22:17 -04:00
helpers.c bpf: Fix bpf_strtol and bpf_strtoul helpers for 32bit 2024-11-08 16:20:31 +01:00
inode.c
local_storage.c
lpm_trie.c bpf, lpm: Fix check prefixlen before walking trie 2024-01-25 14:34:24 -08:00
Makefile
map_in_map.c bpf: Add map and need_defer parameters to .map_fd_put_ptr() 2024-02-23 08:24:57 +01:00
map_in_map.h bpf: Add map and need_defer parameters to .map_fd_put_ptr() 2024-02-23 08:24:57 +01:00
offload.c
percpu_freelist.c
percpu_freelist.h
queue_stack_maps.c bpf: Avoid deadlock when using queue and stack maps from NMI 2023-10-10 21:46:36 +02:00
reuseport_array.c
stackmap.c bpf: Fix stackmap overflow check on 32-bit arches 2024-03-26 18:22:17 -04:00
syscall.c
sysfs_btf.c
tnum.c
verifier.c bpf: Fix precision tracking for BPF_ALU | BPF_TO_BE | BPF_END 2023-11-28 16:50:18 +00:00
xskmap.c