]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: btf: Check members of struct/union
authorMartin KaFai Lau <kafai@fb.com>
Wed, 18 Apr 2018 22:55:59 +0000 (15:55 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 19 Apr 2018 19:46:24 +0000 (21:46 +0200)
commitc70c57aa9b3af328af2add5d26800f050048137f
tree2c336fb5ccae57da2a4d8a1eeb117664ffc40a11
parentfeac4292a86d99da44616d74a4dea85ea6eab8bd
bpf: btf: Check members of struct/union

This patch checks a few things of struct's members:

1) It has a valid size (e.g. a "const void" is invalid)
2) A member's size (+ its member's offset) does not exceed
   the containing struct's size.
3) The member's offset satisfies the alignment requirement

The above can only be done after the needs_resolve member's type
is resolved.  Hence, the above is done together in
btf_struct_resolve().

Each possible member's type (e.g. int, enum, modifier...) implements
the check_member() ops which will be called from btf_struct_resolve().

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Alexei Starovoitov <ast@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/btf.c