bpf: fix incorrect sign extension in check_alu_op()
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 21 Dec 2017 21:42:49 +0000 (22:42 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 23 Dec 2017 00:39:51 +0000 (00:39 +0000)
commitd51c3d753b058db59349f41bb356eadb0d4730d4
treeaed8948924b6fee663e815c9125425ea4054f39e
parentd84291b592f9581b4b50cb47e9787886bcb340d2
bpf: fix incorrect sign extension in check_alu_op()

Distinguish between
BPF_ALU64|BPF_MOV|BPF_K (load 32-bit immediate, sign-extended to 64-bit)
and BPF_ALU|BPF_MOV|BPF_K (load 32-bit immediate, zero-padded to 64-bit);
only perform sign extension in the first case.

Starting with v4.14, this is exploitable by unprivileged users as long as
the unprivileged_bpf_disabled sysctl isn't set.

Debian assigned CVE-2017-16995 for this issue.

v3:
 - add CVE number (Ben Hutchings)

Fixes: 484611357c19 ("bpf: allow access into map value arrays")
Signed-off-by: Jann Horn <jannh@google.com>
Acked-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name bpf-fix-incorrect-sign-extension-in-check_alu_op.patch
kernel/bpf/verifier.c