bpf: teach refsafe() to take into account ID remapping
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 23 Dec 2022 05:49:15 +0000 (21:49 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 28 Dec 2022 01:37:07 +0000 (17:37 -0800)
commite8f55fcf77794c9867a5edbcb84baf21609465a7
tree4066f941e90acf035f881aa37e836f1cc065a8f4
parentcfca00767febba5f4f5e300fab10e0974491dd4b
bpf: teach refsafe() to take into account ID remapping

states_equal() check performs ID mapping between old and new states to
establish a 1-to-1 correspondence between IDs, even if their absolute
numberic values across two equivalent states differ. This is important
both for correctness and to avoid unnecessary work when two states are
equivalent.

With recent changes we partially fixed this logic by maintaining ID map
across all function frames. This patch also makes refsafe() check take
into account (and maintain) ID map, making states_equal() behavior more
optimal and correct.

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