]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Explicitly size compatible_reg_types
authorLorenz Bauer <lmb@cloudflare.com>
Wed, 23 Sep 2020 16:01:55 +0000 (17:01 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 23 Sep 2020 18:46:46 +0000 (11:46 -0700)
commit2157eec1930023fbef24e19591bcbacb2f68a988
tree119e9fb88d0db8851514aefc6e5c6c1f69fd6dbc
parentd037d6462e8cba78206fc0d57847dd072cc5b9cf
bpf: Explicitly size compatible_reg_types

Arrays with designated initializers have an implicit length of the highest
initialized value plus one. I used this to ensure that newly added entries
in enum bpf_reg_type get a NULL entry in compatible_reg_types.

This is difficult to understand since it requires knowledge of the
peculiarities of designated initializers. Use __BPF_ARG_TYPE_MAX to size
the array instead.

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200923160156.80814-1-lmb@cloudflare.com
kernel/bpf/verifier.c