]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
bpf: Change return value of verifier function add_subprog()
authorYonghong Song <yhs@fb.com>
Fri, 26 Feb 2021 20:49:24 +0000 (12:49 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 26 Feb 2021 21:23:52 +0000 (13:23 -0800)
Currently, verifier function add_subprog() returns 0 for success
and negative value for failure. Change the return value
to be the subprog number for success. This functionality will be
used in the next patch to save a call to find_subprog().

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210226204924.3884848-1-yhs@fb.com
kernel/bpf/verifier.c

index 97e772f44cd77839ef7a99c4e869d555a657692b..dbdca49ac6cc479ca0d4b413bc7470eb05d89eaa 100644 (file)
@@ -1530,7 +1530,7 @@ static int add_subprog(struct bpf_verifier_env *env, int off)
        }
        ret = find_subprog(env, off);
        if (ret >= 0)
-               return 0;
+               return ret;
        if (env->subprog_cnt >= BPF_MAX_SUBPROGS) {
                verbose(env, "too many subprograms\n");
                return -E2BIG;
@@ -1538,7 +1538,7 @@ static int add_subprog(struct bpf_verifier_env *env, int off)
        env->subprog_info[env->subprog_cnt++].start = off;
        sort(env->subprog_info, env->subprog_cnt,
             sizeof(env->subprog_info[0]), cmp_subprogs, NULL);
-       return 0;
+       return env->subprog_cnt - 1;
 }
 
 static int check_subprogs(struct bpf_verifier_env *env)