aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/test_verifier.c
diff options
context:
space:
mode:
authorMartin Lau <kafai@fb.com>2018-10-24 20:42:25 +0000
committerDaniel Borkmann <daniel@iogearbox.net>2018-10-26 00:42:03 +0200
commit4a6998aff82a20a1aece86a186d8e5263f8b2315 (patch)
tree894c34812dfa0157c7ebc6e49be6d1b60c73d19c /tools/testing/selftests/bpf/test_verifier.c
parentselftests/bpf: add config fragments BPF_STREAM_PARSER and XDP_SOCKETS (diff)
downloadlinux-dev-4a6998aff82a20a1aece86a186d8e5263f8b2315.tar.xz
linux-dev-4a6998aff82a20a1aece86a186d8e5263f8b2315.zip
bpf, btf: fix a missing check bug in btf_parse
Wenwen Wang reported: In btf_parse(), the header of the user-space btf data 'btf_data' is firstly parsed and verified through btf_parse_hdr(). In btf_parse_hdr(), the header is copied from user-space 'btf_data' to kernel-space 'btf->hdr' and then verified. If no error happens during the verification process, the whole data of 'btf_data', including the header, is then copied to 'data' in btf_parse(). It is obvious that the header is copied twice here. More importantly, no check is enforced after the second copy to make sure the headers obtained in these two copies are same. Given that 'btf_data' resides in the user space, a malicious user can race to modify the header between these two copies. By doing so, the user can inject inconsistent data, which can cause undefined behavior of the kernel and introduce potential security risk. This issue is similar to the one fixed in commit 8af03d1ae2e1 ("bpf: btf: Fix a missing check bug"). To fix it, this patch copies the user 'btf_data' *before* parsing / verifying the BTF header. Fixes: 69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)") Signed-off-by: Martin KaFai Lau <kafai@fb.com> Co-developed-by: Wenwen Wang <wang6495@umn.edu> Acked-by: Song Liu <songliubraving@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/test_verifier.c')
0 files changed, 0 insertions, 0 deletions