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.
This commit is contained in:
Andreas Kling 2018-10-26 12:22:22 +02:00
parent 546ddd7de0
commit 0af9254812

View file

@ -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);