Skip to content

Commit 512809b

Browse files
pchaignoAlexei Starovoitov
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> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/e4d7b53d4963ef520541a782f5fc8108a168877c.1778176504.git.paul.chaignon@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 18fc650 commit 512809b

1 file changed

Lines changed: 7 additions & 18 deletions

File tree

kernel/bpf/liveness.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,26 +1914,15 @@ 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
/*
1927-
* Subprogs and callbacks that don't receive FP-derived arguments
1928-
* cannot access ancestor stack frames, so they were skipped during
1929-
* the recursive walk above. Async callbacks (timer, workqueue) are
1930-
* also not reachable from the main program's call graph. Analyze
1931-
* all unvisited subprogs as independent roots at depth 0.
1918+
* Analyze every subprog in reverse topological order (callers
1919+
* before callees) so that each subprog is analyzed before its
1920+
* callees, allowing the recursive walk inside analyze_subprog()
1921+
* to naturally reach callees that receive FP-derived args.
19321922
*
1933-
* Use reverse topological order (callers before callees) so that
1934-
* each subprog is analyzed before its callees, allowing the
1935-
* recursive walk inside analyze_subprog() to naturally
1936-
* reach nested callees that also lack FP-derived args.
1923+
* Subprogs and callbacks that don't receive FP-derived arguments
1924+
* cannot access ancestor stack frames are analyzed independently.
1925+
* Async callbacks (timer, workqueue) are handled the same way.
19371926
*/
19381927
for (k = env->subprog_cnt - 1; k >= 0; k--) {
19391928
int sub = env->subprog_topo_order[k];

0 commit comments

Comments
 (0)