]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: Ensure off_reg has no mixed signed bounds for all types
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 23 Mar 2021 07:51:02 +0000 (08:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Apr 2021 11:13:28 +0000 (13:13 +0200)
commit1611010fa388974b61cd6362c49d3fd1e31e2126
tree10d5e6c777f09b46504993f5ee52579b477b904e
parent0c197aa38386054d3e9c3379c682608db0151439
bpf: Ensure off_reg has no mixed signed bounds for all types

[ Upstream commit 24c109bb1537c12c02aeed2d51a347b4d6a9b76e ]

The mixed signed bounds check really belongs into retrieve_ptr_limit()
instead of outside of it in adjust_ptr_min_max_vals(). The reason is
that this check is not tied to PTR_TO_MAP_VALUE only, but to all pointer
types that we handle in retrieve_ptr_limit() and given errors from the latter
propagate back to adjust_ptr_min_max_vals() and lead to rejection of the
program, it's a better place to reside to avoid anything slipping through
for future types. The reason why we must reject such off_reg is that we
otherwise would not be able to derive a mask, see details in 9d7eceede769
("bpf: restrict unknown scalars of mixed signed bounds for unprivileged").

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/verifier.c