]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
libbpf: Fix hypothetical STT_SECTION extern NULL deref case
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 20 Feb 2025 00:28:21 +0000 (16:28 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:31:59 +0000 (14:31 +0200)
commitb28c6712afb6ce395fd3fbc1ea399f37944a4f13
tree7cc5c6074705584408be4169bad8237b0fd36d3b
parentbe6a831b44feb4eb0066cfd8803673e53e0d81fd
libbpf: Fix hypothetical STT_SECTION extern NULL deref case

[ Upstream commit e0525cd72b5979d8089fe524a071ea93fd011dc9 ]

Fix theoretical NULL dereference in linker when resolving *extern*
STT_SECTION symbol against not-yet-existing ELF section. Not sure if
it's possible in practice for valid ELF object files (this would require
embedded assembly manipulations, at which point BTF will be missing),
but fix the s/dst_sym/dst_sec/ typo guarding this condition anyways.

Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs")
Fixes: a46349227cd8 ("libbpf: Add linker extern resolution support for functions and global variables")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20250220002821.834400-1-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/lib/bpf/linker.c