]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Use proper target btf when exporting attach_btf_obj_id
authorStanislav Fomichev <sdf@google.com>
Thu, 4 Aug 2022 20:11:39 +0000 (13:11 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 8 Aug 2022 13:53:17 +0000 (15:53 +0200)
commitcd3d51f3e80f51770c8e093caa7a26bb685fb8f2
tree1e03f9cee39a4d071d54bc204637672175a43257
parentbb845057f241120a0c5352814c3d400175290312
bpf: Use proper target btf when exporting attach_btf_obj_id

When attaching to program, the program itself might not be attached
to anything (and, hence, might not have attach_btf), so we can't
unconditionally use 'prog->aux->dst_prog->aux->attach_btf'.

Instead, use bpf_prog_get_target_btf to pick proper target BTF:

  * when attached to dst_prog, use dst_prog->aux->btf
  * when attached to kernel btf, use prog->aux->attach_btf

Fixes: 49731902a6fb ("bpf: implement BPF_PROG_QUERY for BPF_LSM_CGROUP")
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Hao Luo <haoluo@google.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20220804201140.1340684-1-sdf@google.com
kernel/bpf/syscall.c