]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix an unitialized value in bpf_iter
authorYonghong Song <yhs@fb.com>
Fri, 12 Feb 2021 00:59:26 +0000 (16:59 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Feb 2021 21:33:50 +0000 (13:33 -0800)
commit5b5a1006bf7d4024b87b5e732596cd5a783e61a5
tree34a79d7c80beb57fff98e0ea1077e2b06e0192e8
parent0886702f4a1748fc4b6f361f1e48a967a8c6d328
bpf: Fix an unitialized value in bpf_iter

Commit d224c790ffd6 ("bpf: Allow loading of a bpf_iter program")
cached btf_id in struct bpf_iter_target_info so later on
if it can be checked cheaply compared to checking registered names.

syzbot found a bug that uninitialized value may occur to
bpf_iter_target_info->btf_id. This is because we allocated
bpf_iter_target_info structure with kmalloc and never initialized
field btf_id afterwards. This uninitialized btf_id is typically
compared to a u32 bpf program func proto btf_id, and the chance
of being equal is extremely slim.

This patch fixed the issue by using kzalloc which will also
prevent future likely instances due to adding new fields.

Fixes: d224c790ffd6 ("bpf: Allow loading of a bpf_iter program")
Reported-by: syzbot+580f4f2a272e452d55cb@syzkaller.appspotmail.com
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210212005926.2875002-1-yhs@fb.com
kernel/bpf/bpf_iter.c