diff options
| author | Jessica Clarke <jrtc27@FreeBSD.org> | 2026-07-29 14:09:42 +0000 |
|---|---|---|
| committer | Jessica Clarke <jrtc27@FreeBSD.org> | 2026-07-29 14:09:42 +0000 |
| commit | 1e39a314d870e312f623199e146eda6bdbc293a3 (patch) | |
| tree | 4a5efb69d3ecb9fa8bd55bbc9ec5e0aca1a82f35 | |
| parent | b6823a973737f06ea6cf0ea5a3083383af2ba5a4 (diff) | |
link_elf: Make phdrs first page check actually fatal
Otherwise we'll print an error but carry on regardless, presumably
destined to walk off the end of the mapping.
Reported by: thebugfixers@pm.me
MFC after: 1 week
| -rw-r--r-- | sys/kern/link_elf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index 613dfe0133d4..6ab5f4a39580 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -1086,8 +1086,11 @@ link_elf_load_file(linker_class_t cls, const char* filename, */ if (!((hdr->e_phentsize == sizeof(Elf_Phdr)) && (hdr->e_phoff + hdr->e_phnum*sizeof(Elf_Phdr) <= PAGE_SIZE) && - (hdr->e_phoff + hdr->e_phnum*sizeof(Elf_Phdr) <= nbytes))) + (hdr->e_phoff + hdr->e_phnum*sizeof(Elf_Phdr) <= nbytes))) { link_elf_error(filename, "Unreadable program headers"); + error = ENOEXEC; + goto out; + } /* * Scan the program header entries, and save key information. |
