New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support BTF_KIND_TYPE_TAG for btf_type_tag attributes #2100
Conversation
Master branch: 3a74ac2 |
Master branch: 3a74ac2 |
b4197d8
to
15a87ee
Compare
Master branch: 1a8b597 |
15a87ee
to
de1e418
Compare
Master branch: 04f8cb6 |
de1e418
to
faaefba
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=577773 expired. Closing PR. |
Master branch: 04f8cb6 |
faaefba
to
158f955
Compare
Master branch: 3a75111 Pull request is NOT updated. Failed to apply https://patchwork.kernel.org/project/netdevbpf/list/?series=578993
conflict:
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=578993 expired. Closing PR. |
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 Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Add libbpf support for BTF_KIND_TYPE_TAG. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Add bpftool support for BTF_KIND_TYPE_TAG. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Add unit tests for btf__add_type_tag(). Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Add BTF_KIND_TYPE_TAG unit tests. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Add BTF_KIND_TYPE_TAG duplication unit tests. Signed-off-by: Yonghong Song <yhs@fb.com>
Rename progs/tag.c to progs/btf_decl_tag.c so we can introduce progs/btf_type_tag.c in the next patch. Also create a subtest for btf_decl_tag in prog_tests/btf_tag.c so we can introduce btf_type_tag subtest in the next patch. I also took opportunity to remove the check whether __has_attribute is defined or not in progs/btf_decl_tag.c since all recent clangs should already support this macro. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
The following is the main btf_type_tag usage in the C test: #define __tag1 __attribute__((btf_type_tag("tag1"))) #define __tag2 __attribute__((btf_type_tag("tag2"))) struct btf_type_tag_test { int __tag1 * __tag1 __tag2 *p; } g; The bpftool raw dump with related types: [4] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [11] STRUCT 'btf_type_tag_test' size=8 vlen=1 'p' type_id=14 bits_offset=0 [12] TYPE_TAG 'tag1' type_id=16 [13] TYPE_TAG 'tag2' type_id=12 [14] PTR '(anon)' type_id=13 [15] TYPE_TAG 'tag1' type_id=4 [16] PTR '(anon)' type_id=15 [17] VAR 'g' type_id=11, linkage=global With format C dump, we have struct btf_type_tag_test { int __attribute__((btf_type_tag("tag1"))) * __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag2"))) *p; }; The result C code is identical to the original definition except macro's are gone. Signed-off-by: Yonghong Song <yhs@fb.com>
btf_tag selftest needs certain llvm versions (>= llvm14). Make it clear in the selftests README.rst file. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Add BTF_KIND_TYPE_TAG documentation in btf.rst. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Master branch: 2326ff8 |
158f955
to
602c269
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=579013 irrelevant now. Closing PR. |
Pull request for series with
subject: Support BTF_KIND_TYPE_TAG for btf_type_tag attributes
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=577773