@@ -4677,12 +4677,13 @@ static void mark_all_scalars_imprecise(struct bpf_verifier_env *env, struct bpf_
4677
4677
* mark_all_scalars_imprecise() to hopefully get more permissive and generic
4678
4678
* finalized states which help in short circuiting more future states.
4679
4679
*/
4680
- static int __mark_chain_precision(struct bpf_verifier_env *env, int regno)
4680
+ static int __mark_chain_precision(struct bpf_verifier_env *env,
4681
+ struct bpf_verifier_state *starting_state, int regno)
4681
4682
{
4683
+ struct bpf_verifier_state *st = starting_state;
4682
4684
struct backtrack_state *bt = &env->bt;
4683
- struct bpf_verifier_state *st = env->cur_state;
4684
4685
int first_idx = st->first_insn_idx;
4685
- int last_idx = env ->insn_idx;
4686
+ int last_idx = starting_state ->insn_idx;
4686
4687
int subseq_idx = -1;
4687
4688
struct bpf_func_state *func;
4688
4689
struct bpf_reg_state *reg;
@@ -4693,7 +4694,7 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int regno)
4693
4694
return 0;
4694
4695
4695
4696
/* set frame number from which we are starting to backtrack */
4696
- bt_init(bt, env->cur_state ->curframe);
4697
+ bt_init(bt, starting_state ->curframe);
4697
4698
4698
4699
/* Do sanity checks against current state of register and/or stack
4699
4700
* slot, but don't set precise flag in current state, as precision
@@ -4757,7 +4758,7 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int regno)
4757
4758
err = backtrack_insn(env, i, subseq_idx, hist, bt);
4758
4759
}
4759
4760
if (err == -ENOTSUPP) {
4760
- mark_all_scalars_precise(env, env->cur_state );
4761
+ mark_all_scalars_precise(env, starting_state );
4761
4762
bt_reset(bt);
4762
4763
return 0;
4763
4764
} else if (err) {
@@ -4845,7 +4846,7 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int regno)
4845
4846
* fallback to marking all precise
4846
4847
*/
4847
4848
if (!bt_empty(bt)) {
4848
- mark_all_scalars_precise(env, env->cur_state );
4849
+ mark_all_scalars_precise(env, starting_state );
4849
4850
bt_reset(bt);
4850
4851
}
4851
4852
@@ -4854,15 +4855,16 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int regno)
4854
4855
4855
4856
int mark_chain_precision(struct bpf_verifier_env *env, int regno)
4856
4857
{
4857
- return __mark_chain_precision(env, regno);
4858
+ return __mark_chain_precision(env, env->cur_state, regno);
4858
4859
}
4859
4860
4860
4861
/* mark_chain_precision_batch() assumes that env->bt is set in the caller to
4861
4862
* desired reg and stack masks across all relevant frames
4862
4863
*/
4863
- static int mark_chain_precision_batch(struct bpf_verifier_env *env)
4864
+ static int mark_chain_precision_batch(struct bpf_verifier_env *env,
4865
+ struct bpf_verifier_state *starting_state)
4864
4866
{
4865
- return __mark_chain_precision(env, -1);
4867
+ return __mark_chain_precision(env, starting_state, -1);
4866
4868
}
4867
4869
4868
4870
static bool is_spillable_regtype(enum bpf_reg_type type)
@@ -9515,7 +9517,7 @@ static int get_constant_map_key(struct bpf_verifier_env *env,
9515
9517
* to prevent pruning on it.
9516
9518
*/
9517
9519
bt_set_frame_slot(&env->bt, key->frameno, spi);
9518
- err = mark_chain_precision_batch(env);
9520
+ err = mark_chain_precision_batch(env, env->cur_state );
9519
9521
if (err < 0)
9520
9522
return err;
9521
9523
@@ -18939,7 +18941,7 @@ static int propagate_precision(struct bpf_verifier_env *env,
18939
18941
verbose(env, "\n");
18940
18942
}
18941
18943
18942
- err = mark_chain_precision_batch(env);
18944
+ err = mark_chain_precision_batch(env, env->cur_state );
18943
18945
if (err < 0)
18944
18946
return err;
18945
18947
0 commit comments