bpf: perform byte-by-byte comparison only when necessary in regsafe()
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 23 Dec 2022 05:49:19 +0000 (21:49 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 28 Dec 2022 01:37:07 +0000 (17:37 -0800)
commit4a95c85c994801c9ae12d9cb7216da7b484564b3
tree10dde7a47d86533a0523c911b44385f6ac50f563
parent910f69996674bfc4a273a335c1fb2ecb45062bf6
bpf: perform byte-by-byte comparison only when necessary in regsafe()

Extract byte-by-byte comparison of bpf_reg_state in regsafe() into
a helper function, which makes it more convenient to use it "on demand"
only for registers that benefit from such checks, instead of doing it
all the time, even if result of such comparison is ignored.

Also, remove WARN_ON_ONCE(1)+return false dead code. There is no risk of
missing some case as compiler will warn about non-void function not
returning value in some branches (and that under assumption that default
case is removed in the future).

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20221223054921.958283-6-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c