OSDN Git Service

bpf: fix sanitation of alu op with pointer / scalar type from different paths
authorDaniel Borkmann <daniel@iogearbox.net>
Mon, 28 Jan 2019 20:28:29 +0000 (21:28 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 Jan 2019 07:14:41 +0000 (08:14 +0100)
commiteed84f94ff8d97abcbc5706f6f9427520fd60a10
tree1d122dd41bdc99835375e2c9b34c7d9a5cc6365e
parentf92a819b4cbef8c9527d9797110544b2055a4b96
bpf: fix sanitation of alu op with pointer / scalar type from different paths

[ commit d3bd7413e0ca40b60cf60d4003246d067cafdeda upstream ]

While 979d63d50c0c ("bpf: prevent out of bounds speculation on pointer
arithmetic") took care of rejecting alu op on pointer when e.g. pointer
came from two different map values with different map properties such as
value size, Jann reported that a case was not covered yet when a given
alu op is used in both "ptr_reg += reg" and "numeric_reg += reg" from
different branches where we would incorrectly try to sanitize based
on the pointer's limit. Catch this corner case and reject the program
instead.

Fixes: 979d63d50c0c ("bpf: prevent out of bounds speculation on pointer arithmetic")
Reported-by: Jann Horn <jannh@google.com>
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>
include/linux/bpf_verifier.h
kernel/bpf/verifier.c