git: f93ab5858523 - stable/14 - link_elf: Make phdrs first page check actually fatal
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 06 Aug 2026 18:04:59 UTC
The branch stable/14 has been updated by jrtc27:
URL: https://cgit.FreeBSD.org/src/commit/?id=f93ab585852341bd5b8635cab1df7020eb677bd8
commit f93ab585852341bd5b8635cab1df7020eb677bd8
Author: Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2026-07-29 14:09:42 +0000
Commit: Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2026-08-06 18:04:28 +0000
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
(cherry picked from commit 1e39a314d870e312f623199e146eda6bdbc293a3)
---
sys/kern/link_elf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index bcce79a8b262..18826b7a6360 100644
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -1062,8 +1062,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.