@@ -18500,15 +18500,17 @@ static bool refsafe(struct bpf_verifier_state *old, struct bpf_verifier_state *c
18500
18500
* the current state will reach 'bpf_exit' instruction safely
18501
18501
*/
18502
18502
static bool func_states_equal(struct bpf_verifier_env *env, struct bpf_func_state *old,
18503
- struct bpf_func_state *cur, enum exact_level exact)
18503
+ struct bpf_func_state *cur, u32 insn_idx, enum exact_level exact)
18504
18504
{
18505
- int i;
18505
+ u16 live_regs = env->insn_aux_data[insn_idx].live_regs_before;
18506
+ u16 i;
18506
18507
18507
18508
if (old->callback_depth > cur->callback_depth)
18508
18509
return false;
18509
18510
18510
18511
for (i = 0; i < MAX_BPF_REG; i++)
18511
- if (!regsafe(env, &old->regs[i], &cur->regs[i],
18512
+ if (((1 << i) & live_regs) &&
18513
+ !regsafe(env, &old->regs[i], &cur->regs[i],
18512
18514
&env->idmap_scratch, exact))
18513
18515
return false;
18514
18516
@@ -18529,6 +18531,7 @@ static bool states_equal(struct bpf_verifier_env *env,
18529
18531
struct bpf_verifier_state *cur,
18530
18532
enum exact_level exact)
18531
18533
{
18534
+ u32 insn_idx;
18532
18535
int i;
18533
18536
18534
18537
if (old->curframe != cur->curframe)
@@ -18552,9 +18555,12 @@ static bool states_equal(struct bpf_verifier_env *env,
18552
18555
* and all frame states need to be equivalent
18553
18556
*/
18554
18557
for (i = 0; i <= old->curframe; i++) {
18558
+ insn_idx = i == old->curframe
18559
+ ? env->insn_idx
18560
+ : old->frame[i + 1]->callsite;
18555
18561
if (old->frame[i]->callsite != cur->frame[i]->callsite)
18556
18562
return false;
18557
- if (!func_states_equal(env, old->frame[i], cur->frame[i], exact))
18563
+ if (!func_states_equal(env, old->frame[i], cur->frame[i], insn_idx, exact))
18558
18564
return false;
18559
18565
}
18560
18566
return true;
0 commit comments