From 0af9254812cb560109ccc6fec2e9c3077e3338fc Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 26 Oct 2018 12:22:22 +0200 Subject: [PATCH] If spawning a task fails after we did a partial ELF load, remap current. This is an annoying issue. It'd be nice if this code didn't have to worry about preserving the calling task's mappings. --- Kernel/Task.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Kernel/Task.cpp b/Kernel/Task.cpp index e7abce35d2..798cfb2c5f 100644 --- a/Kernel/Task.cpp +++ b/Kernel/Task.cpp @@ -243,6 +243,9 @@ Task* Task::createUserTask(const String& path, uid_t uid, gid_t gid, pid_t paren }; bool success = space.loadELF(move(elfData)); if (!success) { + // FIXME: This is ugly. If we need to do this, it should be at a different level. + MemoryManager::the().unmapRegionsForTask(*t); + MemoryManager::the().mapRegionsForTask(*current); delete t; kprintf("Failure loading ELF %s\n", path.characters()); error = -ENOEXEC; @@ -251,11 +254,15 @@ Task* Task::createUserTask(const String& path, uid_t uid, gid_t gid, pid_t paren t->m_tss.eip = (dword)space.symbolPtr("_start"); if (!t->m_tss.eip) { + // FIXME: This is ugly. If we need to do this, it should be at a different level. + MemoryManager::the().unmapRegionsForTask(*t); + MemoryManager::the().mapRegionsForTask(*current); delete t; error = -ENOEXEC; return nullptr; } + // FIXME: This is ugly. If we need to do this, it should be at a different level. MemoryManager::the().unmapRegionsForTask(*t); MemoryManager::the().mapRegionsForTask(*current);