bpf: fix NULL deref in btf_type_is_resolve_source_only
Commit1dc9285184("bpf: kernel side support for BTF Var and DataSec") added invocations of btf_type_is_resolve_source_only before btf_type_nosize_or_null which checks for the NULL pointer. Swap the order of btf_type_nosize_or_null and btf_type_is_resolve_source_only to make sure the do the NULL pointer check first. Fixes:1dc9285184("bpf: kernel side support for BTF Var and DataSec") Reported-by: syzbot <syzkaller@googlegroups.com> Signed-off-by: Stanislav Fomichev <sdf@google.com> Acked-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
committed by
Daniel Borkmann
parent
56f0f84e69
commit
e4f0712021
@@ -1928,8 +1928,8 @@ static int btf_array_resolve(struct btf_verifier_env *env,
|
|||||||
/* Check array->index_type */
|
/* Check array->index_type */
|
||||||
index_type_id = array->index_type;
|
index_type_id = array->index_type;
|
||||||
index_type = btf_type_by_id(btf, index_type_id);
|
index_type = btf_type_by_id(btf, index_type_id);
|
||||||
if (btf_type_is_resolve_source_only(index_type) ||
|
if (btf_type_nosize_or_null(index_type) ||
|
||||||
btf_type_nosize_or_null(index_type)) {
|
btf_type_is_resolve_source_only(index_type)) {
|
||||||
btf_verifier_log_type(env, v->t, "Invalid index");
|
btf_verifier_log_type(env, v->t, "Invalid index");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@@ -1948,8 +1948,8 @@ static int btf_array_resolve(struct btf_verifier_env *env,
|
|||||||
/* Check array->type */
|
/* Check array->type */
|
||||||
elem_type_id = array->type;
|
elem_type_id = array->type;
|
||||||
elem_type = btf_type_by_id(btf, elem_type_id);
|
elem_type = btf_type_by_id(btf, elem_type_id);
|
||||||
if (btf_type_is_resolve_source_only(elem_type) ||
|
if (btf_type_nosize_or_null(elem_type) ||
|
||||||
btf_type_nosize_or_null(elem_type)) {
|
btf_type_is_resolve_source_only(elem_type)) {
|
||||||
btf_verifier_log_type(env, v->t,
|
btf_verifier_log_type(env, v->t,
|
||||||
"Invalid elem");
|
"Invalid elem");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -2170,8 +2170,8 @@ static int btf_struct_resolve(struct btf_verifier_env *env,
|
|||||||
const struct btf_type *member_type = btf_type_by_id(env->btf,
|
const struct btf_type *member_type = btf_type_by_id(env->btf,
|
||||||
member_type_id);
|
member_type_id);
|
||||||
|
|
||||||
if (btf_type_is_resolve_source_only(member_type) ||
|
if (btf_type_nosize_or_null(member_type) ||
|
||||||
btf_type_nosize_or_null(member_type)) {
|
btf_type_is_resolve_source_only(member_type)) {
|
||||||
btf_verifier_log_member(env, v->t, member,
|
btf_verifier_log_member(env, v->t, member,
|
||||||
"Invalid member");
|
"Invalid member");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|||||||
Reference in New Issue
Block a user