libbpf: Fix logic for finding matching program for CO-RE relocation
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 26 Apr 2022 00:45:04 +0000 (17:45 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:22:51 +0000 (10:22 +0200)
commit32c7cbb75b368a3e2c2560b078c9778406823f2d
treeb13e46c154ab81255fee58f97e3b364c25474c4b
parent2324985aa700457738fe737216140fb4f3d3f14a
libbpf: Fix logic for finding matching program for CO-RE relocation

[ Upstream commit 966a7509325395c51c5f6d89e7352b0585e4804b ]

Fix the bug in bpf_object__relocate_core() which can lead to finding
invalid matching BPF program when processing CO-RE relocation. IF
matching program is not found, last encountered program will be assumed
to be correct program and thus error detection won't detect the problem.

Fixes: 9c82a63cf370 ("libbpf: Fix CO-RE relocs against .text section")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220426004511.2691730-4-andrii@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/lib/bpf/libbpf.c