mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
Kernel: Fix race causing modifying a Process to fail with a panic
The ProtectedDataMutationScope cannot blindly assume that there is only exactly one thread at a time that may want to unprotect the Process. Most of the time the big lock guaranteed this, but there are some cases such as finalization (among others) where this is not necessarily guaranteed. This fixes random panics due to access violations when the ProtectedDataMutationScope protects the Process instance while another is still modifying it. Fixes #8512
This commit is contained in:
parent
942bb976e2
commit
a95b726fd8
Notes:
sideshowbarker
2024-07-18 10:08:58 +09:00
Author: https://github.com/tomuta
Commit: a95b726fd8
Pull-request: https://github.com/SerenityOS/serenity/pull/8518
Issue: https://github.com/SerenityOS/serenity/issues/8512
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/gunnarbeutner ✅
2 changed files with 8 additions and 2 deletions
|
@ -205,12 +205,16 @@ RefPtr<Process> Process::create_kernel_process(RefPtr<Thread>& first_thread, Str
|
|||
|
||||
void Process::protect_data()
|
||||
{
|
||||
MM.set_page_writable_direct(VirtualAddress { this }, false);
|
||||
m_protected_data_refs.unref([&]() {
|
||||
MM.set_page_writable_direct(VirtualAddress { this }, false);
|
||||
});
|
||||
}
|
||||
|
||||
void Process::unprotect_data()
|
||||
{
|
||||
MM.set_page_writable_direct(VirtualAddress { this }, true);
|
||||
m_protected_data_refs.ref([&]() {
|
||||
MM.set_page_writable_direct(VirtualAddress { this }, true);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<Process> Process::create(RefPtr<Thread>& first_thread, const String& name, uid_t uid, gid_t gid, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd, RefPtr<Custody> executable, TTY* tty, Process* fork_parent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue