1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

Kernel: Add back missing ELF::Image validity check

If the image is not a valid ELF we should just fail ASAP.
This commit is contained in:
Andreas Kling 2020-12-25 14:06:19 +01:00
parent 4986f268a5
commit c3eddbcb49

View file

@ -75,6 +75,11 @@ KResultOr<Process::LoadResult> Process::load_elf_object(FileDescription& object_
return KResult(-ENOMEM);
}
auto elf_image = ELF::Image(region->vaddr().as_ptr(), loader_metadata.size);
if (!elf_image.is_valid())
return KResult(-ENOEXEC);
Region* master_tls_region { nullptr };
size_t master_tls_size = 0;
size_t master_tls_alignment = 0;
@ -83,8 +88,6 @@ KResultOr<Process::LoadResult> Process::load_elf_object(FileDescription& object_
MM.enter_process_paging_scope(*this);
String elf_name = object_description.absolute_path();
auto elf_image = ELF::Image(region->vaddr().as_ptr(), loader_metadata.size);
ASSERT(!Processor::current().in_critical());
bool failed = false;