Skip to content

Commit 2660fef

Browse files
pchaignoKernel Patches Daemon
authored andcommitted
bpf: Don't run arg-tracking analysis twice on main subprog
Because subprog 0, the main subprog, is considered a global function, we end up running the arg-tracking dataflow analysis twice on it. That results in slightly longer verification but mostly in more verbose verifier logs. This patch fixes it by keeping only the iteration over global subprogs. When running over all of Cilium's programs with BPF_LOG_LEVEL2, this reduces verbosity by ~20% on average. Fixes: bf0c571 ("bpf: introduce forward arg-tracking dataflow analysis") Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
1 parent 010a7e6 commit 2660fef

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

kernel/bpf/liveness.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,15 +1914,6 @@ int bpf_compute_subprog_arg_access(struct bpf_verifier_env *env)
19141914
return -ENOMEM;
19151915
}
19161916

1917-
instance = call_instance(env, NULL, 0, 0);
1918-
if (IS_ERR(instance)) {
1919-
err = PTR_ERR(instance);
1920-
goto out;
1921-
}
1922-
err = analyze_subprog(env, NULL, info, instance, callsites);
1923-
if (err)
1924-
goto out;
1925-
19261917
/*
19271918
* Subprogs and callbacks that don't receive FP-derived arguments
19281919
* cannot access ancestor stack frames, so they were skipped during
@@ -1934,6 +1925,8 @@ int bpf_compute_subprog_arg_access(struct bpf_verifier_env *env)
19341925
* each subprog is analyzed before its callees, allowing the
19351926
* recursive walk inside analyze_subprog() to naturally
19361927
* reach nested callees that also lack FP-derived args.
1928+
*
1929+
* Note the main subprog is also analyzed as part of this loop.
19371930
*/
19381931
for (k = env->subprog_cnt - 1; k >= 0; k--) {
19391932
int sub = env->subprog_topo_order[k];

0 commit comments

Comments
 (0)