summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-02 10:42:53 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-02 11:20:34 +0100
commite56f8706ce40e903e1897a8175cea65ed8f4760e (patch)
tree1524050b0ee28c5042b63516e4fd3c38a70a04d1 /Kernel
parent678c87087d73812105b5682bb6eb27148d3b7dcb (diff)
downloadserenity-e56f8706ce40e903e1897a8175cea65ed8f4760e.zip
Kernel: Map executables at a kernel address during ELF load
This is both simpler and more robust than mapping them in the process address space.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Process.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 00b172a440..9d67b06681 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -832,9 +832,6 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
dbg() << "Process " << pid() << " exec: PD=" << m_page_directory.ptr() << " created";
#endif
- MM.enter_process_paging_scope(*this);
-
- Region* region { nullptr };
InodeMetadata loader_metadata;
@@ -848,23 +845,22 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
// FIXME: We should be able to load both the PT_INTERP interpreter and the main program... once the RTLD is smart enough
if (interpreter_description) {
loader_metadata = interpreter_description->metadata();
- region = allocate_region_with_vmobject(VirtualAddress(), loader_metadata.size, *vmobject, 0, interpreter_description->absolute_path(), PROT_READ, false);
// we don't need the interpreter file desciption after we've loaded (or not) it into memory
interpreter_description = nullptr;
} else {
loader_metadata = main_program_description->metadata();
- region = allocate_region_with_vmobject(VirtualAddress(), loader_metadata.size, *vmobject, 0, main_program_description->absolute_path(), PROT_READ, false);
}
- ASSERT(region);
-
- region->set_shared(true);
+ auto region = MM.allocate_kernel_region_with_vmobject(*vmobject, PAGE_ROUND_UP(loader_metadata.size), "ELF loading", Region::Access::Read);
+ if (!region)
+ return -ENOMEM;
Region* master_tls_region { nullptr };
size_t master_tls_size = 0;
size_t master_tls_alignment = 0;
u32 entry_eip = 0;
+ MM.enter_process_paging_scope(*this);
OwnPtr<ELFLoader> loader;
{
ArmedScopeGuard rollback_regions_guard([&]() {