]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
libbpf: fix sym_is_subprog() logic for weak global subprogs
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 9 Oct 2024 01:15:54 +0000 (18:15 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2024 12:53:13 +0000 (13:53 +0100)
commitbe8f3d1e4b8731bf133e554ee703cfdadb394c6c
treec734b58f6af12241ede1850f2ff42fab9684e34e
parent0af05e8c7d40f889fc9d3db2e5a1b8533994e68d
libbpf: fix sym_is_subprog() logic for weak global subprogs

[ Upstream commit 4073213488be542f563eb4b2457ab4cbcfc2b738 ]

sym_is_subprog() is incorrectly rejecting relocations against *weak*
global subprogs. Fix that by realizing that STB_WEAK is also a global
function.

While it seems like verifier doesn't support taking an address of
non-static subprog right now, it's still best to fix support for it on
libbpf side, otherwise users will get a very confusing error during BPF
skeleton generation or static linking due to misinterpreted relocation:

  libbpf: prog 'handle_tp': bad map relo against 'foo' in section '.text'
  Error: failed to open BPF object file: Relocation failed

It's clearly not a map relocation, but is treated and reported as such
without this fix.

Fixes: 53eddb5e04ac ("libbpf: Support subprog address relocation")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20241009011554.880168-1-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/lib/bpf/libbpf.c