提交 841d6e8e 编写于 作者: A Andrii Nakryiko 提交者: Zheng Zengkai

selftests/bpf: Fix possible NULL passed to memcpy() with zero size

mainline inclusion
from mainline-5.17-rc1
commit 3bd0233f
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=3bd0233f388e061c44d36a1ac614a3bb4a851b7e

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

Prevent sanitizer from complaining about passing NULL into memcpy(),
even if it happens with zero size.
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20211124002325.1737739-9-andrii@kernel.org
(cherry picked from commit 3bd0233f)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
上级 06fdaf49
...@@ -891,7 +891,8 @@ void test_core_reloc(void) ...@@ -891,7 +891,8 @@ void test_core_reloc(void)
data = mmap_data; data = mmap_data;
memset(mmap_data, 0, sizeof(*data)); memset(mmap_data, 0, sizeof(*data));
memcpy(data->in, test_case->input, test_case->input_len); if (test_case->input_len)
memcpy(data->in, test_case->input, test_case->input_len);
data->my_pid_tgid = my_pid_tgid; data->my_pid_tgid = my_pid_tgid;
link = bpf_program__attach_raw_tracepoint(prog, tp_name); link = bpf_program__attach_raw_tracepoint(prog, tp_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册