mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
kld: Reject kernel modules with PT_LOAD segments where filesz > memsz
All sorts of places in the ELF loading code assume that filesz <= memsz, so check that explicitly up front. Reported by: Jane Smith <[email protected]> (via D57785) Reviewed by: jrtc27, kib Differential Revision: https://reviews.freebsd.org/D58542
This commit is contained in:
1 parent
b9eaf9b7ce
commit
486dfbb67e
1 file changed
+8
@@ -1110,6 +1110,14 @@ link_elf_load_file(linker_class_t cls, const char* filename,
|
||||
error = ENOEXEC;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (phdr->p_memsz < phdr->p_filesz) {
|
||||
link_elf_error(filename,
|
||||
"Invalid program header");
|
||||
error = ENOEXEC;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX: We just trust they come in right order ??
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user