Handle kmod local relocation failures gracefully

It is possible for elf_reloc_local() to fail in the unlikely case of
an unsupported relocation type. If this occurs, do not continue to
process the file.

Reviewed by:	kib, markj (earlier version)
MFC after:	1 week
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D26701
This commit is contained in:
Mitchell Horne 2020-10-07 23:14:49 +00:00
parent 5152b4f74f
commit 44c705cf15

View file

@ -1676,9 +1676,11 @@ link_elf_reloc_local(linker_file_t lf, bool ifuncs)
if (ELF_ST_BIND(sym->st_info) != STB_LOCAL)
continue;
if ((ELF_ST_TYPE(sym->st_info) == STT_GNU_IFUNC ||
elf_is_ifunc_reloc(rel->r_info)) == ifuncs)
elf_reloc_local(lf, base, rel, ELF_RELOC_REL,
elf_obj_lookup);
elf_is_ifunc_reloc(rel->r_info)) != ifuncs)
continue;
if (elf_reloc_local(lf, base, rel, ELF_RELOC_REL,
elf_obj_lookup) != 0)
return (ENOEXEC);
}
}
@ -1704,9 +1706,11 @@ link_elf_reloc_local(linker_file_t lf, bool ifuncs)
if (ELF_ST_BIND(sym->st_info) != STB_LOCAL)
continue;
if ((ELF_ST_TYPE(sym->st_info) == STT_GNU_IFUNC ||
elf_is_ifunc_reloc(rela->r_info)) == ifuncs)
elf_reloc_local(lf, base, rela, ELF_RELOC_RELA,
elf_obj_lookup);
elf_is_ifunc_reloc(rela->r_info)) != ifuncs)
continue;
if (elf_reloc_local(lf, base, rela, ELF_RELOC_RELA,
elf_obj_lookup) != 0)
return (ENOEXEC);
}
}
return (0);