libbpf: Use proper errno value in linker
[ Upstream commit 358b1c0f56ebb6996fcec7dcdcf6bae5dcbc8b6c ]
Return values of the linker_append_sec_data() and the
linker_append_elf_relos() functions are propagated all the
way up to users of libbpf API. In some error cases these
functions return -1 which will be seen as -EPERM from user's
point of view. Instead, return a more reasonable -EINVAL.
Fixes: faf6ed321c
("libbpf: Add BPF static linker APIs")
Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250430120820.2262053-1-a.s.protopopov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
1c005c53cf
commit
1066c5a7d0
@@ -1187,7 +1187,7 @@ static int linker_append_sec_data(struct bpf_linker *linker, struct src_obj *obj
|
|||||||
} else {
|
} else {
|
||||||
if (!secs_match(dst_sec, src_sec)) {
|
if (!secs_match(dst_sec, src_sec)) {
|
||||||
pr_warn("ELF sections %s are incompatible\n", src_sec->sec_name);
|
pr_warn("ELF sections %s are incompatible\n", src_sec->sec_name);
|
||||||
return -1;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "license" and "version" sections are deduped */
|
/* "license" and "version" sections are deduped */
|
||||||
@@ -2034,7 +2034,7 @@ static int linker_append_elf_relos(struct bpf_linker *linker, struct src_obj *ob
|
|||||||
}
|
}
|
||||||
} else if (!secs_match(dst_sec, src_sec)) {
|
} else if (!secs_match(dst_sec, src_sec)) {
|
||||||
pr_warn("sections %s are not compatible\n", src_sec->sec_name);
|
pr_warn("sections %s are not compatible\n", src_sec->sec_name);
|
||||||
return -1;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* shdr->sh_link points to SYMTAB */
|
/* shdr->sh_link points to SYMTAB */
|
||||||
|
Reference in New Issue
Block a user