bpf: restrict unknown scalars of mixed signed bounds for unprivileged
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 3 Apr 2019 18:39:10 +0000 (18:39 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Apr 2019 07:15:09 +0000 (09:15 +0200)
commit17efa65350c5a251ba7d90a56abc65205a204a03
tree3feb8c2fadba9f25daf17348247662999ed6cdd8
parentba9d2e0cc870d1a16195c801aa18b33cd70125b9
bpf: restrict unknown scalars of mixed signed bounds for unprivileged

commit 9d7eceede769f90b66cfa06ad5b357140d5141ed upstream.

For unknown scalars of mixed signed bounds, meaning their smin_value is
negative and their smax_value is positive, we need to reject arithmetic
with pointer to map value. For unprivileged the goal is to mask every
map pointer arithmetic and this cannot reliably be done when it is
unknown at verification time whether the scalar value is negative or
positive. Given this is a corner case, the likelihood of breaking should
be very small.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
[backported to 4.14 sblbir]
Signed-off-by: Balbir Singh <sblbir@amzn.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/verifier.c