]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix a buffer out-of-bound access when filling raw_tp link_info
authorYonghong Song <yhs@fb.com>
Fri, 21 Aug 2020 19:10:54 +0000 (12:10 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 25 Aug 2020 04:03:07 +0000 (21:03 -0700)
commitddf21a0a3c860fb7550c1c5cca9f0703a9d5ef90
treeeb61755165d1e65bdd944d7b48239392c59e31d6
parentb9f3fa12b7581886fdee4ec94e2ce46f43f7a3b3
bpf: Fix a buffer out-of-bound access when filling raw_tp link_info

Commit 7b9e52cbecc8 ("bpf: Add support for BPF_OBJ_GET_INFO_BY_FD for bpf_link")
added link query for raw_tp. One of fields in link_info is to
fill a user buffer with tp_name. The Scurrent checking only
declares "ulen && !ubuf" as invalid. So "!ulen && ubuf" will be
valid. Later on, we do "copy_to_user(ubuf, tp_name, ulen - 1)" which
may overwrite user memory incorrectly.

This patch fixed the problem by disallowing "!ulen && ubuf" case as well.

Fixes: 7b9e52cbecc8 ("bpf: Add support for BPF_OBJ_GET_INFO_BY_FD for bpf_link")
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200821191054.714731-1-yhs@fb.com
kernel/bpf/syscall.c