]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: restrict map value pointer arithmetic for unprivileged
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 3 Apr 2019 18:39:08 +0000 (18:39 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Apr 2019 07:15:08 +0000 (09:15 +0200)
commitafb711a6e8d003eead79432c026f6654ae303fcb
treea99d799768f6bc18c60658482934e4260f1834d0
parentb101cf55c6da31b86ee8144ac0113b7ecfb7c06b
bpf: restrict map value pointer arithmetic for unprivileged

commit 0d6303db7970e6f56ae700fa07e11eb510cda125 upstream.

Restrict map value pointer arithmetic for unprivileged users in that
arithmetic itself must not go out of bounds as opposed to the actual
access later on. Therefore after each adjust_ptr_min_max_vals() with a
map value pointer as a destination it will simulate a check_map_access()
of 1 byte on the destination and once that fails the program is rejected
for unprivileged program loads. We use this later on for masking any
pointer arithmetic with the remainder of the map value space. The
likelihood of breaking any existing real-world unprivileged eBPF
program is very small for this corner case.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/verifier.c