UPSTREAM: bpf: bpf_prog_array_alloc() should return a generic non-rcu pointer
authorRoman Gushchin <guro@fb.com>
Fri, 13 Jul 2018 19:41:10 +0000 (12:41 -0700)
committerCosmin Tanislav <demonsingur@gmail.com>
Thu, 16 May 2024 07:58:25 +0000 (10:58 +0300)
commit26020be5ef6243cbb7cb032c099a9c6fca01758b
tree2870976bb6844d8fd15704a7aa434f7068a06cb5
parent60670b3baf37d045d2d22ea094304d53ede8adb3
UPSTREAM: bpf: bpf_prog_array_alloc() should return a generic non-rcu pointer

Currently the return type of the bpf_prog_array_alloc() is
struct bpf_prog_array __rcu *, which is not quite correct.
Obviously, the returned pointer is a generic pointer, which
is valid for an indefinite amount of time and it's not shared
with anyone else, so there is no sense in marking it as __rcu.

This change eliminate the following sparse warnings:
kernel/bpf/core.c:1544:31: warning: incorrect type in return expression (different address spaces)
kernel/bpf/core.c:1544:31:    expected struct bpf_prog_array [noderef] <asn:4>*
kernel/bpf/core.c:1544:31:    got void *
kernel/bpf/core.c:1548:17: warning: incorrect type in return expression (different address spaces)
kernel/bpf/core.c:1548:17:    expected struct bpf_prog_array [noderef] <asn:4>*
kernel/bpf/core.c:1548:17:    got struct bpf_prog_array *<noident>
kernel/bpf/core.c:1681:15: warning: incorrect type in assignment (different address spaces)
kernel/bpf/core.c:1681:15:    expected struct bpf_prog_array *array
kernel/bpf/core.c:1681:15:    got struct bpf_prog_array [noderef] <asn:4>*

Bug: 254441685
Fixes: 324bda9e6c5a ("bpf: multi program support for cgroup+bpf")
Signed-off-by: Roman Gushchin <guro@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
(cherry picked from commit d29ab6e1fa21ebc2a8a771015dd9e0e5d4e28dc1)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I59d055c81b07be18766203f60a23005ebf340ad9
include/linux/bpf.h
kernel/bpf/core.c