OSDN Git Service

bpf: restrict stack pointer arithmetic for unprivileged
authorDaniel Borkmann <daniel@iogearbox.net>
Mon, 28 Jan 2019 20:28:25 +0000 (21:28 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 Jan 2019 07:14:41 +0000 (08:14 +0100)
commit5332dda94f632e56444d1c081e4683463dd64278
treeec1b1bed2c5557a94680a3efdb75d0de2589ca25
parent9e57b2969d4afa8fe08dda6d658963336c97b594
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>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/verifier.c