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

commit e4298d25830a866cc0f427d4bccb858e76715859 upstream.

Restrict stack 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 stack pointer as a destination we simulate a check_stack_access()
of 1 byte on the destination and once that fails the program is
rejected for unprivileged program loads. This is analog to map
value pointer arithmetic and needed for masking later on.

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