bpf: Support BTF_KIND_TYPE_TAG for btf_type_tag attributes
authorYonghong Song <yhs@fb.com>
Fri, 12 Nov 2021 01:26:09 +0000 (17:26 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Nov 2021 01:41:11 +0000 (17:41 -0800)
commit8c42d2fa4eeab6c37a0b1b1aa7a2715248ef4f34
treec119fc05841e8bdd8667e34b4536e76d8253d727
parent2326ff8d5c6628e581c87f37a8f6db1db7dc00ee
bpf: Support BTF_KIND_TYPE_TAG for btf_type_tag attributes

LLVM patches ([1] for clang, [2] and [3] for BPF backend)
added support for btf_type_tag attributes. This patch
added support for the kernel.

The main motivation for btf_type_tag is to bring kernel
annotations __user, __rcu etc. to btf. With such information
available in btf, bpf verifier can detect mis-usages
and reject the program. For example, for __user tagged pointer,
developers can then use proper helper like bpf_probe_read_user()
etc. to read the data.

BTF_KIND_TYPE_TAG may also useful for other tracing
facility where instead of to require user to specify
kernel/user address type, the kernel can detect it
by itself with btf.

  [1] https://reviews.llvm.org/D111199
  [2] https://reviews.llvm.org/D113222
  [3] https://reviews.llvm.org/D113496

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211112012609.1505032-1-yhs@fb.com
include/uapi/linux/btf.h
kernel/bpf/btf.c
tools/include/uapi/linux/btf.h