]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Add btf_struct_ids_match function
authorJiri Olsa <jolsa@kernel.org>
Tue, 25 Aug 2020 19:21:18 +0000 (21:21 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 25 Aug 2020 22:37:41 +0000 (15:37 -0700)
commite68441dc8a22415dd359afa0815ebdc18e9fc88a
tree8c1f317df4976e485f72c66b0a9c735874b111d9
parentf42fef04443ab6e225af150e4b70a5d3a928be8b
bpf: Add btf_struct_ids_match function

Adding btf_struct_ids_match function to check if given address provided
by BTF object + offset is also address of another nested BTF object.

This allows to pass an argument to helper, which is defined via parent
BTF object + offset, like for bpf_d_path (added in following changes):

  SEC("fentry/filp_close")
  int BPF_PROG(prog_close, struct file *file, void *id)
  {
    ...
    ret = bpf_d_path(&file->f_path, ...

The first bpf_d_path argument is hold by verifier as BTF file object
plus offset of f_path member.

The btf_struct_ids_match function will walk the struct file object and
check if there's nested struct path object on the given offset.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200825192124.710397-9-jolsa@kernel.org
include/linux/bpf.h
kernel/bpf/btf.c
kernel/bpf/verifier.c