loader: fix elf lookup_symbol type filtering
The existing logic doesn't seem to make much sense, as we won't filter on the type if st_shndx != SHN_UNDEF. In practice, this breaks booting 12.3 kernels on newer loaders, as they do have a `kernphys` symbol of the wrong type (NOTYPE, rather than OBJECT) -- we end up deriving the wrong value for copy_staging. It's unclear if this version makes any more sense, but it seems to match what rtld's matched_symbol() does. Loader doesn't need to care about STT_FUNC w/ UND shndx, because we won't encounter those; in kmods, undefined (kernel) functions are NOTYPE. Approved by: so Security: FreeBSD-EN-22:27.loader Reported by: Christian McDonald <cmcdonald netgate com> Reviewed by: imp, kib, tsoome (cherry picked from commit0701dbda94
) (cherry picked from commit2b31059ea7
)
This commit is contained in:
parent
6df214f547
commit
707882874d
|
@ -1259,9 +1259,8 @@ __elfN(lookup_symbol)(elf_file_t ef, const char* name, Elf_Sym *symp,
|
||||||
strp = strdupout((vm_offset_t)(ef->strtab + sym.st_name));
|
strp = strdupout((vm_offset_t)(ef->strtab + sym.st_name));
|
||||||
if (strcmp(name, strp) == 0) {
|
if (strcmp(name, strp) == 0) {
|
||||||
free(strp);
|
free(strp);
|
||||||
if (sym.st_shndx != SHN_UNDEF ||
|
if (sym.st_shndx != SHN_UNDEF && sym.st_value != 0 &&
|
||||||
(sym.st_value != 0 &&
|
ELF_ST_TYPE(sym.st_info) == type) {
|
||||||
ELF_ST_TYPE(sym.st_info) == type)) {
|
|
||||||
*symp = sym;
|
*symp = sym;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue