Skip to content

Commit 652a3df

Browse files
anakryikogregkh
authored andcommitted
libbpf: Fix hypothetical STT_SECTION extern NULL deref case
[ Upstream commit e0525cd ] 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: faf6ed3 ("libbpf: Add BPF static linker APIs") Fixes: a463492 ("libbpf: Add linker extern resolution support for functions and global variables") Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 73fd28b commit 652a3df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/lib/bpf/linker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,7 @@ static int linker_append_elf_sym(struct bpf_linker *linker, struct src_obj *obj,
20072007

20082008
obj->sym_map[src_sym_idx] = dst_sym_idx;
20092009

2010-
if (sym_type == STT_SECTION && dst_sym) {
2010+
if (sym_type == STT_SECTION && dst_sec) {
20112011
dst_sec->sec_sym_idx = dst_sym_idx;
20122012
dst_sym->st_value = 0;
20132013
}

0 commit comments

Comments
 (0)