提交 3a49def0 编写于 作者: Y Yonghong Song 提交者: Zheng Zengkai

bpf: Change return value of verifier function add_subprog()

mainline inclusion
from mainline-5.13-rc1
commit 282a0f46
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=282a0f46d6cda7cf843cd77c9b53b4d1d9e31302

-------------------------------------------------

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: NYonghong Song <yhs@fb.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Acked-by: NAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210226204924.3884848-1-yhs@fb.com
(cherry picked from commit 282a0f46)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
上级 bf5adef7
...@@ -1513,7 +1513,7 @@ static int add_subprog(struct bpf_verifier_env *env, int off) ...@@ -1513,7 +1513,7 @@ static int add_subprog(struct bpf_verifier_env *env, int off)
} }
ret = find_subprog(env, off); ret = find_subprog(env, off);
if (ret >= 0) if (ret >= 0)
return 0; return ret;
if (env->subprog_cnt >= BPF_MAX_SUBPROGS) { if (env->subprog_cnt >= BPF_MAX_SUBPROGS) {
verbose(env, "too many subprograms\n"); verbose(env, "too many subprograms\n");
return -E2BIG; return -E2BIG;
...@@ -1521,7 +1521,7 @@ static int add_subprog(struct bpf_verifier_env *env, int off) ...@@ -1521,7 +1521,7 @@ static int add_subprog(struct bpf_verifier_env *env, int off)
env->subprog_info[env->subprog_cnt++].start = off; env->subprog_info[env->subprog_cnt++].start = off;
sort(env->subprog_info, env->subprog_cnt, sort(env->subprog_info, env->subprog_cnt,
sizeof(env->subprog_info[0]), cmp_subprogs, NULL); sizeof(env->subprog_info[0]), cmp_subprogs, NULL);
return 0; return env->subprog_cnt - 1;
} }
static int check_subprogs(struct bpf_verifier_env *env) static int check_subprogs(struct bpf_verifier_env *env)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册