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.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -1914,26 +1914,15 @@ int bpf_compute_subprog_arg_access(struct bpf_verifier_env *env) · 1913 unmodified lines | |||
| 1914 | return -ENOMEM; | 1914 | return -ENOMEM; |
| 1915 | } | 1915 | } |
| 1916 | 1916 | ||
| 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 | |||
| 1926 | /* | 1917 | /* |
| 1927 | * Subprogs and callbacks that don't receive FP-derived arguments | 1918 | * Analyze every subprog in reverse topological order (callers |
| 1928 | * cannot access ancestor stack frames, so they were skipped during | 1919 | * before callees) so that each subprog is analyzed before its |
| 1929 | * the recursive walk above. Async callbacks (timer, workqueue) are | 1920 | * callees, allowing the recursive walk inside analyze_subprog() |
| 1930 | * also not reachable from the main program's call graph. Analyze | 1921 | * to naturally reach callees that receive FP-derived args. |
| 1931 | * all unvisited subprogs as independent roots at depth 0. | ||
| 1932 | * | 1922 | * |
| 1933 | * Use reverse topological order (callers before callees) so that | 1923 | * Subprogs and callbacks that don't receive FP-derived arguments |
| 1934 | * each subprog is analyzed before its callees, allowing the | 1924 | * cannot access ancestor stack frames are analyzed independently. |
| 1935 | * recursive walk inside analyze_subprog() to naturally | 1925 | * Async callbacks (timer, workqueue) are handled the same way. |
| 1936 | * reach nested callees that also lack FP-derived args. | ||
| 1937 | */ | 1926 | */ |
| 1938 | for (k = env->subprog_cnt - 1; k >= 0; k--) { | 1927 | for (k = env->subprog_cnt - 1; k >= 0; k--) { |
| 1939 | int sub = env->subprog_topo_order[k]; | 1928 | int sub = env->subprog_topo_order[k]; |