diff options
| author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2019-01-23 01:45:23 -0500 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2019-01-23 20:35:32 -0500 |
| commit | 9e4c24e7ee7dfd3898269519103e823892b730d8 (patch) | |
| tree | b62ec0289acccf464e0fc6bcee8fd3417f4bc24c /kernel/bpf | |
| parent | cb05077508bf3635fcf1637fdb30136559555c65 (diff) | |
bpf: verifier: record original instruction index
The communication between the verifier and advanced JITs is based
on instruction indexes. We have to keep them stable throughout
the optimizations otherwise referring to a particular instruction
gets messy quickly.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf')
| -rw-r--r-- | kernel/bpf/verifier.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index f39bca188a5c..f2c49b4235df 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c | |||
| @@ -7371,7 +7371,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, | |||
| 7371 | { | 7371 | { |
| 7372 | struct bpf_verifier_env *env; | 7372 | struct bpf_verifier_env *env; |
| 7373 | struct bpf_verifier_log *log; | 7373 | struct bpf_verifier_log *log; |
| 7374 | int ret = -EINVAL; | 7374 | int i, len, ret = -EINVAL; |
| 7375 | bool is_priv; | 7375 | bool is_priv; |
| 7376 | 7376 | ||
| 7377 | /* no program is valid */ | 7377 | /* no program is valid */ |
| @@ -7386,12 +7386,14 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, | |||
| 7386 | return -ENOMEM; | 7386 | return -ENOMEM; |
| 7387 | log = &env->log; | 7387 | log = &env->log; |
| 7388 | 7388 | ||
| 7389 | len = (*prog)->len; | ||
| 7389 | env->insn_aux_data = | 7390 | env->insn_aux_data = |
| 7390 | vzalloc(array_size(sizeof(struct bpf_insn_aux_data), | 7391 | vzalloc(array_size(sizeof(struct bpf_insn_aux_data), len)); |
| 7391 | (*prog)->len)); | ||
| 7392 | ret = -ENOMEM; | 7392 | ret = -ENOMEM; |
| 7393 | if (!env->insn_aux_data) | 7393 | if (!env->insn_aux_data) |
| 7394 | goto err_free_env; | 7394 | goto err_free_env; |
| 7395 | for (i = 0; i < len; i++) | ||
| 7396 | env->insn_aux_data[i].orig_idx = i; | ||
| 7395 | env->prog = *prog; | 7397 | env->prog = *prog; |
| 7396 | env->ops = bpf_verifier_ops[env->prog->type]; | 7398 | env->ops = bpf_verifier_ops[env->prog->type]; |
| 7397 | 7399 | ||
