Skip to content

Support BTF_KIND_TYPE_TAG for btf_type_tag attributes

Yonghong Song bpf 3 versions – Applied

Status from this message: Applied. Thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest10 patches 1 replyApplied
  2. v210 patches 0 repliesSuperseded
  3. v110 patches 19 repliesSuperseded

Changes in v3 from the cover letter

- rebase to resolve merge conflicts.

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/10bpf: Support BTF_KIND_TYPE_TAG for btf_type_tag attributesinclude/uapi/linux/btf.h kernel/bpf/btf.c tools/include/uapi/linux/btf.h+17 -30 replies
2/10libbpf: Support BTF_KIND_TYPE_TAGtools/lib/bpf/btf.c tools/lib/bpf/btf.h tools/lib/bpf/btf_dump.c +3 more+73 -20 replies
3/10bpftool: Support BTF_KIND_TYPE_TAGtools/bpf/bpftool/btf.c+2 -00 replies
4/10selftests/bpf: Test libbpf API function btf__add_type_tag()tools/testing/selftests/bpf/btf_helpers.c tools/testing/selftests/bpf/prog_tests/btf_write.c+43 -280 replies
5/10selftests/bpf: Add BTF_KIND_TYPE_TAG unit teststools/testing/selftests/bpf/prog_tests/btf.c tools/testing/selftests/bpf/test_btf.h+21 -00 replies
6/10selftests/bpf: Test BTF_KIND_DECL_TAG for deduplicationtools/testing/selftests/bpf/prog_tests/btf.c+135 -40 replies
7/10selftests/bpf: Rename progs/tag.c to progs/btf_decl_tag.ctools/testing/selftests/bpf/prog_tests/btf_tag.c tools/testing/selftests/bpf/progs/btf_decl_tag.c+13 -110 replies
8/10selftests/bpf: Add a C test for btf_type_tagtools/testing/selftests/bpf/prog_tests/btf_tag.c tools/testing/selftests/bpf/progs/btf_type_tag.c+49 -00 replies
9/10selftests/bpf: Clarify llvm dependency with btf_tag selftesttools/testing/selftests/bpf/README.rst+5 -40 replies
10/10docs/bpf: Update documentation for BTF_KIND_TYPE_TAG supportDocumentation/bpf/btf.rst+12 -10 replies

Reviews trailers per patch

8 of 10 patches have a Reviewed-by or Acked-by.

PatchAndrii Nakryiko
1/10A-b
2/10A-b
3/10A-b
4/10A-b
5/10A-b
6/10
7/10A-b
8/10
9/10A-b
10/10A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH bpf-next v3 00/10] 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_kernel() 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.

Patch 1 added support in kernel, Patch 2 for libbpf and Patch 3 for bpftool. Patches 4-9 are for bpf selftests and Patch 10 updated docs/bpf/btf.rst file with new btf kind.

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

Changelogs:
v2 -> v3:
- rebase to resolve merge conflicts.
v1 -> v2:
- add more dedup tests.
- remove build requirement for LLVM=1.
- remove testing macro __has_attribute in bpf programs as it is always defined in recent clang compilers.

Yonghong Song (10):
bpf: Support BTF_KIND_TYPE_TAG for btf_type_tag attributes
libbpf: Support BTF_KIND_TYPE_TAG
bpftool: Support BTF_KIND_TYPE_TAG
selftests/bpf: Test libbpf API function btf__add_type_tag() selftests/bpf: Add BTF_KIND_TYPE_TAG unit tests selftests/bpf: Test BTF_KIND_DECL_TAG for deduplication selftests/bpf: Rename progs/tag.c to progs/btf_decl_tag.c selftests/bpf: Add a C test for btf_type_tag selftests/bpf: Clarify llvm dependency with btf_tag selftest docs/bpf: Update documentation for BTF_KIND_TYPE_TAG support

 Documentation/bpf/btf.rst                     |  13 +-
 include/uapi/linux/btf.h                      |   3 +-
 kernel/bpf/btf.c                              |  14 +-
 tools/bpf/bpftool/btf.c                       |   2 +
 tools/include/uapi/linux/btf.h                |   3 +-
 tools/lib/bpf/btf.c                           |  23 +++
 tools/lib/bpf/btf.h                           |   9 +-
 tools/lib/bpf/btf_dump.c                      |   9 +
 tools/lib/bpf/libbpf.c                        |  31 +++-
 tools/lib/bpf/libbpf.map                      |   1 +
 tools/lib/bpf/libbpf_internal.h               |   2 +
 tools/testing/selftests/bpf/README.rst        |   9 +-
 tools/testing/selftests/bpf/btf_helpers.c     |   4 +-
 tools/testing/selftests/bpf/prog_tests/btf.c  | 157 +++++++++++++++++-
 .../selftests/bpf/prog_tests/btf_tag.c        |  44 ++++-
 .../selftests/bpf/prog_tests/btf_write.c      |  67 +++++---
 .../bpf/progs/{tag.c => btf_decl_tag.c}       |   4 -
 .../selftests/bpf/progs/btf_type_tag.c        |  25 +++
 tools/testing/selftests/bpf/test_btf.h        |   3 +
 19 files changed, 370 insertions(+), 53 deletions(-)
 rename tools/testing/selftests/bpf/progs/{tag.c => btf_decl_tag.c} (94%)
 create mode 100644 tools/testing/selftests/bpf/progs/btf_type_tag.c
Signature · 1 line
2.30.2