* [PATCH bpf] bpf: fix NULL deref in btf_type_is_resolve_source_only
@ 2019-06-19 19:01 Stanislav Fomichev
2019-06-19 19:08 ` Andrii Nakryiko
2019-06-24 13:54 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Stanislav Fomichev @ 2019-06-19 19:01 UTC (permalink / raw)
To: netdev, bpf; +Cc: davem, ast, daniel, Stanislav Fomichev, syzbot
Commit 1dc92851849c ("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: 1dc92851849c ("bpf: kernel side support for BTF Var and DataSec")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
kernel/bpf/btf.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index cad09858a5f2..546ebee39e2a 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -1928,8 +1928,8 @@ static int btf_array_resolve(struct btf_verifier_env *env,
/* Check array->index_type */
index_type_id = array->index_type;
index_type = btf_type_by_id(btf, index_type_id);
- if (btf_type_is_resolve_source_only(index_type) ||
- btf_type_nosize_or_null(index_type)) {
+ if (btf_type_nosize_or_null(index_type) ||
+ btf_type_is_resolve_source_only(index_type)) {
btf_verifier_log_type(env, v->t, "Invalid index");
return -EINVAL;
}
@@ -1948,8 +1948,8 @@ static int btf_array_resolve(struct btf_verifier_env *env,
/* Check array->type */
elem_type_id = array->type;
elem_type = btf_type_by_id(btf, elem_type_id);
- if (btf_type_is_resolve_source_only(elem_type) ||
- btf_type_nosize_or_null(elem_type)) {
+ if (btf_type_nosize_or_null(elem_type) ||
+ btf_type_is_resolve_source_only(elem_type)) {
btf_verifier_log_type(env, v->t,
"Invalid elem");
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,
member_type_id);
- if (btf_type_is_resolve_source_only(member_type) ||
- btf_type_nosize_or_null(member_type)) {
+ if (btf_type_nosize_or_null(member_type) ||
+ btf_type_is_resolve_source_only(member_type)) {
btf_verifier_log_member(env, v->t, member,
"Invalid member");
return -EINVAL;
--
2.22.0.410.gd8fdbe21b5-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: fix NULL deref in btf_type_is_resolve_source_only
2019-06-19 19:01 [PATCH bpf] bpf: fix NULL deref in btf_type_is_resolve_source_only Stanislav Fomichev
@ 2019-06-19 19:08 ` Andrii Nakryiko
2019-06-24 13:54 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2019-06-19 19:08 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: Networking, bpf, David S. Miller, Alexei Starovoitov,
Daniel Borkmann, syzbot
On Wed, Jun 19, 2019 at 12:01 PM Stanislav Fomichev <sdf@google.com> wrote:
>
> Commit 1dc92851849c ("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: 1dc92851849c ("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>
> kernel/bpf/btf.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index cad09858a5f2..546ebee39e2a 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -1928,8 +1928,8 @@ static int btf_array_resolve(struct btf_verifier_env *env,
> /* Check array->index_type */
> index_type_id = array->index_type;
> index_type = btf_type_by_id(btf, index_type_id);
> - if (btf_type_is_resolve_source_only(index_type) ||
> - btf_type_nosize_or_null(index_type)) {
> + if (btf_type_nosize_or_null(index_type) ||
> + btf_type_is_resolve_source_only(index_type)) {
> btf_verifier_log_type(env, v->t, "Invalid index");
> return -EINVAL;
> }
> @@ -1948,8 +1948,8 @@ static int btf_array_resolve(struct btf_verifier_env *env,
> /* Check array->type */
> elem_type_id = array->type;
> elem_type = btf_type_by_id(btf, elem_type_id);
> - if (btf_type_is_resolve_source_only(elem_type) ||
> - btf_type_nosize_or_null(elem_type)) {
> + if (btf_type_nosize_or_null(elem_type) ||
> + btf_type_is_resolve_source_only(elem_type)) {
> btf_verifier_log_type(env, v->t,
> "Invalid elem");
> 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,
> member_type_id);
>
> - if (btf_type_is_resolve_source_only(member_type) ||
> - btf_type_nosize_or_null(member_type)) {
> + if (btf_type_nosize_or_null(member_type) ||
> + btf_type_is_resolve_source_only(member_type)) {
> btf_verifier_log_member(env, v->t, member,
> "Invalid member");
> return -EINVAL;
> --
> 2.22.0.410.gd8fdbe21b5-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: fix NULL deref in btf_type_is_resolve_source_only
2019-06-19 19:01 [PATCH bpf] bpf: fix NULL deref in btf_type_is_resolve_source_only Stanislav Fomichev
2019-06-19 19:08 ` Andrii Nakryiko
@ 2019-06-24 13:54 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2019-06-24 13:54 UTC (permalink / raw)
To: Stanislav Fomichev, netdev, bpf; +Cc: davem, ast, syzbot
On 06/19/2019 09:01 PM, Stanislav Fomichev wrote:
> Commit 1dc92851849c ("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: 1dc92851849c ("bpf: kernel side support for BTF Var and DataSec")
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-24 13:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-19 19:01 [PATCH bpf] bpf: fix NULL deref in btf_type_is_resolve_source_only Stanislav Fomichev
2019-06-19 19:08 ` Andrii Nakryiko
2019-06-24 13:54 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).