]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
bpf: Add PTR_TO_BTF_ID_OR_NULL support
authorYonghong Song <yhs@fb.com>
Sat, 9 May 2020 17:59:12 +0000 (10:59 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 10 May 2020 00:05:26 +0000 (17:05 -0700)
commitb121b341e5983bdccf7a5d6cf9236a45c965a31f
treecf9b12cb78f31f1be6df106598fcaf4874da1245
parenteaaacd23910f2d7c4b22d43f591002cc217d294b
bpf: Add PTR_TO_BTF_ID_OR_NULL support

Add bpf_reg_type PTR_TO_BTF_ID_OR_NULL support.
For tracing/iter program, the bpf program context
definition, e.g., for previous bpf_map target, looks like
  struct bpf_iter__bpf_map {
    struct bpf_iter_meta *meta;
    struct bpf_map *map;
  };

The kernel guarantees that meta is not NULL, but
map pointer maybe NULL. The NULL map indicates that all
objects have been traversed, so bpf program can take
proper action, e.g., do final aggregation and/or send
final report to user space.

Add btf_id_or_null_non0_off to prog->aux structure, to
indicate that if the context access offset is not 0,
set to PTR_TO_BTF_ID_OR_NULL instead of PTR_TO_BTF_ID.
This bit is set for tracing/iter program.

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/20200509175912.2476576-1-yhs@fb.com
include/linux/bpf.h
kernel/bpf/btf.c
kernel/bpf/verifier.c