diff options
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 8f434485abd2..016ef9025827 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -874,11 +874,17 @@ static const struct bpf_prog_ops * const bpf_prog_types[] = { | |||
874 | 874 | ||
875 | static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog) | 875 | static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog) |
876 | { | 876 | { |
877 | if (type >= ARRAY_SIZE(bpf_prog_types) || !bpf_prog_types[type]) | 877 | const struct bpf_prog_ops *ops; |
878 | |||
879 | if (type >= ARRAY_SIZE(bpf_prog_types)) | ||
880 | return -EINVAL; | ||
881 | type = array_index_nospec(type, ARRAY_SIZE(bpf_prog_types)); | ||
882 | ops = bpf_prog_types[type]; | ||
883 | if (!ops) | ||
878 | return -EINVAL; | 884 | return -EINVAL; |
879 | 885 | ||
880 | if (!bpf_prog_is_dev_bound(prog->aux)) | 886 | if (!bpf_prog_is_dev_bound(prog->aux)) |
881 | prog->aux->ops = bpf_prog_types[type]; | 887 | prog->aux->ops = ops; |
882 | else | 888 | else |
883 | prog->aux->ops = &bpf_offload_prog_ops; | 889 | prog->aux->ops = &bpf_offload_prog_ops; |
884 | prog->type = type; | 890 | prog->type = type; |