bpf: Don't promote bogus looking registers after null check.
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 5 Jan 2022 19:35:13 +0000 (11:35 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 09:54:00 +0000 (10:54 +0100)
commit342332fb0be64a28fd5f13809b73bd1d620638c5
tree75012f60a018ef0a1c7e4641501b60b716283525
parent0036c78c492a3175bef6178899a0f438289723e2
bpf: Don't promote bogus looking registers after null check.

[ Upstream commit e60b0d12a95dcf16a63225cead4541567f5cb517 ]

If we ever get to a point again where we convert a bogus looking <ptr>_or_null
typed register containing a non-zero fixed or variable offset, then lets not
reset these bounds to zero since they are not and also don't promote the register
to a <ptr> type, but instead leave it as <ptr>_or_null. Converting to a unknown
register could be an avenue as well, but then if we run into this case it would
allow to leak a kernel pointer this way.

Fixes: f1174f77b50c ("bpf/verifier: rework value tracking")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/verifier.c