Skip to content

bpf: btf: check name validity for various types

Yonghong Song netdev 2 versions – Applied

Status from this message: Applied to bpf tree. Thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 1 replyApplied
  2. v13 patches 2 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/4bpf: btf: implement btf_name_valid_identifier()kernel/bpf/btf.c+25 -00 replies
2/4bpf: btf: check name validity for various typeskernel/bpf/btf.c+57 -00 replies
3/4tools/bpf: fix two test_btf unit test casestools/testing/selftests/bpf/test_btf.c+7 -70 replies
4/4tools/bpf: add addition type tests to test_btftools/testing/selftests/bpf/test_btf.c+361 -00 replies

Reviews trailers per patch

2 of 4 patches have a Reviewed-by or Acked-by.

PatchMartin KaFai Lau
1/4
2/4A-b
3/4
4/4A-b

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

Read the v2 thread

Cover letter [PATCH bpf v2 0/4] bpf: btf: check name validity for various types

This patch set added name checking for PTR, ARRAY, VOLATILE, TYPEDEF, CONST, RESTRICT, STRUCT, UNION, ENUM and FWD types. Such a strict name checking makes BTF more sound in the kernel and future BTF-to-header-file converesion ([1]) less fragile.

Patch #1 implemented btf_name_valid_identifier() for name checking which will be used in Patch #2.
Patch #2 checked name validity for the above mentioned types. Patch #3 fixed two existing test_btf unit tests exposed by the strict name checking.
Patch #4 added additional test cases.

This patch set is against bpf tree.

Patch #1 has been implemented in bpf-next commit
Commit 2667a2626f4d ("bpf: btf: Add BTF_KIND_FUNC
and BTF_KIND_FUNC_PROTO"), so there is no need to apply this patch to bpf-next. In case this patch is applied to bpf-next, there will be a minor conflict like
diff --cc kernel/bpf/btf.c
index a09b2f94ab25,93c233ab2db6..000000000000
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@@ -474,7 -451,7 +474,11 @@@ static bool btf_name_valid_identifier(c

          return !*src;
    }

++<<<<<<< HEAD
+const char *btf_name_by_offset(const struct btf *btf, u32 offset)
++=======
+ static const char *btf_name_by_offset(const struct btf *btf, u32 offset) ++>>>>>>> fa9566b0847d... bpf: btf: implement btf_name_valid_identifier()

    {
          if (!offset)
                  return "(anon)";

Just resolve the conflict by taking the "const char ..." line.

Patches #2, #3 and #4 can be applied to bpf-next without conflict.

[1]: http://vger.kernel.org/lpc-bpf2018.html#session-2

Yonghong Song (4):
bpf: btf: implement btf_name_valid_identifier()
bpf: btf: check name validity for various types
tools/bpf: fix two test_btf unit test cases
tools/bpf: add addition type tests to test_btf

 kernel/bpf/btf.c                       |  82 ++++++
 tools/testing/selftests/bpf/test_btf.c | 375 ++++++++++++++++++++++++-
 2 files changed, 450 insertions(+), 7 deletions(-)
Signature · 1 line
2.17.1