bpf: btf: check name validity for various types
authorYonghong Song <yhs@fb.com>
Tue, 27 Nov 2018 21:23:28 +0000 (13:23 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 29 Nov 2018 00:03:04 +0000 (16:03 -0800)
commiteb04bbb608e683f8fd3ef7f716e2fa32dd90861f
tree6d47467adedc8fcb0d9586db66ba4661a2f550d7
parentcdbb096adddb3f42584cecb5ec2e07c26815b71f
bpf: btf: check name validity for various types

This patch added name checking for the following types:
 . BTF_KIND_PTR, BTF_KIND_ARRAY, BTF_KIND_VOLATILE,
   BTF_KIND_CONST, BTF_KIND_RESTRICT:
     the name must be null
 . BTF_KIND_STRUCT, BTF_KIND_UNION: the struct/member name
     is either null or a valid identifier
 . BTF_KIND_ENUM: the enum type name is either null or a valid
     identifier; the enumerator name must be a valid identifier.
 . BTF_KIND_FWD: the name must be a valid identifier
 . BTF_KIND_TYPEDEF: the name must be a valid identifier

For those places a valid name is required, the name must be
a valid C identifier. This can be relaxed later if we found
use cases for a different (non-C) frontend.

Fixes: 69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)")
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/btf.c