diff options
author | Yonghong Song <yhs@fb.com> | 2019-01-29 16:38:16 -0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-01-29 19:15:32 -0800 |
commit | 81f5c6f5db37bf2360b64c304b27b8f499b48367 (patch) | |
tree | 615e00a0f12827c9b0cac76c6bf38710e1642683 /kernel | |
parent | 2fa53f8924223e81cd85e19f0c2caf110f086752 (diff) | |
download | linux-81f5c6f5db37bf2360b64c304b27b8f499b48367.tar.gz linux-81f5c6f5db37bf2360b64c304b27b8f499b48367.tar.bz2 linux-81f5c6f5db37bf2360b64c304b27b8f499b48367.zip |
bpf: btf: allow typedef func_proto
Current implementation does not allow typedef func_proto.
But it is actually allowed.
-bash-4.4$ cat t.c
typedef int (f) (int);
f *g;
-bash-4.4$ clang -O2 -g -c -target bpf t.c -Xclang -target-feature -Xclang +dwarfris
-bash-4.4$ pahole -JV t.o
File t.o:
[1] PTR (anon) type_id=2
[2] TYPEDEF f type_id=3
[3] FUNC_PROTO (anon) return=4 args=(4 (anon))
[4] INT int size=4 bit_offset=0 nr_bits=32 encoding=SIGNED
-bash-4.4$
This patch related btf verifier to allow such (typedef func_proto)
patterns.
Fixes: 2667a2626f4d ("bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO")
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/btf.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index befe570be5ba..c57bd10340ed 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -1459,7 +1459,8 @@ static int btf_modifier_resolve(struct btf_verifier_env *env, /* "typedef void new_void", "const void"...etc */ if (!btf_type_is_void(next_type) && - !btf_type_is_fwd(next_type)) { + !btf_type_is_fwd(next_type) && + !btf_type_is_func_proto(next_type)) { btf_verifier_log_type(env, v->t, "Invalid type_id"); return -EINVAL; } |