bpf: Enable bpf_iter targets registering ctx argument types
authorYonghong Song <yhs@fb.com>
Wed, 13 May 2020 18:02:21 +0000 (11:02 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 13 May 2020 19:30:50 +0000 (12:30 -0700)
commit3c32cc1bceba8a1755dc35cd97516f6c67856844
tree10e978c4bc1374703070d8ecee9e4e007b13183b
parentab2ee4fcb9d61fd57db70db694adbcf54662bd80
bpf: Enable bpf_iter targets registering ctx argument types

Commit b121b341e598 ("bpf: Add PTR_TO_BTF_ID_OR_NULL
support") adds a field btf_id_or_null_non0_off to
bpf_prog->aux structure to indicate that the
first ctx argument is PTR_TO_BTF_ID reg_type and
all others are PTR_TO_BTF_ID_OR_NULL.
This approach does not really scale if we have
other different reg types in the future, e.g.,
a pointer to a buffer.

This patch enables bpf_iter targets registering ctx argument
reg types which may be different from the default one.
For example, for pointers to structures, the default reg_type
is PTR_TO_BTF_ID for tracing program. The target can register
a particular pointer type as PTR_TO_BTF_ID_OR_NULL which can
be used by the verifier to enforce accesses.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200513180221.2949882-1-yhs@fb.com
include/linux/bpf.h
include/net/ip6_fib.h
kernel/bpf/bpf_iter.c
kernel/bpf/btf.c
kernel/bpf/map_iter.c
kernel/bpf/task_iter.c
kernel/bpf/verifier.c
net/ipv6/ip6_fib.c
net/ipv6/route.c
net/netlink/af_netlink.c