mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Kernel: Don't reuse old master TLS region data in sys$execve()
When switching to the new address space, we also have to switch the
Process::m_master_tls_* variables as they may refer to a region in
the old address space.
This was causing `su` to not run correctly.
Regression from 65641187ff
.
This commit is contained in:
parent
44dd824764
commit
9264303f5d
Notes:
sideshowbarker
2024-07-17 06:51:48 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9264303f5d
@ -490,16 +490,25 @@ ErrorOr<void> Process::do_exec(NonnullRefPtr<OpenFileDescription> main_program_d
|
||||
|
||||
auto allocated_space = TRY(Memory::AddressSpace::try_create(*this, nullptr));
|
||||
OwnPtr<Memory::AddressSpace> old_space;
|
||||
auto old_master_tls_region = m_master_tls_region;
|
||||
auto old_master_tls_size = m_master_tls_size;
|
||||
auto old_master_tls_alignment = m_master_tls_alignment;
|
||||
auto& new_space = m_space.with([&](auto& space) -> Memory::AddressSpace& {
|
||||
old_space = move(space);
|
||||
space = move(allocated_space);
|
||||
return *space;
|
||||
});
|
||||
m_master_tls_region = nullptr;
|
||||
m_master_tls_size = 0;
|
||||
m_master_tls_alignment = 0;
|
||||
ArmedScopeGuard space_guard([&]() {
|
||||
// If we failed at any point from now on we have to revert back to the old address space
|
||||
m_space.with([&](auto& space) {
|
||||
space = old_space.release_nonnull();
|
||||
});
|
||||
m_master_tls_region = old_master_tls_region;
|
||||
m_master_tls_size = old_master_tls_size;
|
||||
m_master_tls_alignment = old_master_tls_alignment;
|
||||
Memory::MemoryManager::enter_process_address_space(*this);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user