bpf: Move map/prog compatibility checks
authorAnton Protopopov <aspsk@isovalent.com>
Fri, 13 Dec 2024 13:09:29 +0000 (13:09 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 13 Dec 2024 22:45:58 +0000 (14:45 -0800)
commit928f3221cb141bdb40d5cc6efe5e7b10adecfe5f
tree8b546a5a00c35a12d461b9e1b209a91174085047
parent4e885fab7164689f031a6c73522a3d91674c5bdc
bpf: Move map/prog compatibility checks

Move some inlined map/prog compatibility checks from the
resolve_pseudo_ldimm64() function to the dedicated
check_map_prog_compatibility() function. Call the latter function
from the add_used_map_from_fd() function directly.

This simplifies code and optimizes logic a bit, as before these
changes the check_map_prog_compatibility() function was executed on
every map usage, which doesn't make sense, as it doesn't include any
per-instruction checks, only map type vs. prog type.

(This patch also simplifies a consequent patch which will call the
add_used_map_from_fd() function from another code path.)

Signed-off-by: Anton Protopopov <aspsk@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241213130934.1087929-3-aspsk@isovalent.com
kernel/bpf/verifier.c