On Thu, 15 Feb 2024 at 02:01, Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > On Thu, 2024-02-01 at 04:20 +0000, Kumar Kartikeya Dwivedi wrote: > > [...] > > > +static int mark_exception_reachable_subprogs(struct bpf_verifier_env *env) > > +{ > > [...] > > > +restart: > > + subprog_end = subprog[idx + 1].start; > > + for (; i < subprog_end; i++) { > > [...] > > > + if (!bpf_pseudo_call(insn + i) && !bpf_pseudo_func(insn + i)) > > + continue; > > + /* remember insn and function to return to */ > > + ret_insn[frame] = i + 1; > > + ret_prog[frame] = idx; > > + > > + /* find the callee */ > > + next_insn = i + insn[i].imm + 1; > > + sidx = find_subprog(env, next_insn); > > + if (sidx < 0) { > > + WARN_ONCE(1, "verifier bug. No program starts at insn %d\n", next_insn); > > + return -EFAULT; > > + } > > For programs like: > > foo(): > bar() > bar() > > this algorithm would scan bar() multiple times. > Would it be possible to remember if subprogram had been scanned > already and reuse collected .is_throw_reachable info? > Good idea, I will look into avoiding this. I think check_max_stack_depth would also benefit from such a change, and since I plan on consolidating both to use similar logic, I will make the change for both. > [...] > >