1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:07:43 +00:00

Kernel: Remove ProcessInspectionHandle and make Process RefCounted

By making the Process class RefCounted we don't really need
ProcessInspectionHandle anymore. This also fixes some race
conditions where a Process may be deleted while still being
used by ProcFS.

Also make sure to acquire the Process' lock when accessing
regions.

Last but not least, there's no reason why a thread can't be
scheduled while being inspected, though in practice it won't
happen anyway because the scheduler lock is held at the same
time.
This commit is contained in:
Tom 2020-08-01 20:04:56 -06:00 committed by Andreas Kling
parent 5bbf6ed46b
commit 538b985487
13 changed files with 191 additions and 273 deletions

View file

@ -33,7 +33,7 @@ int Process::sys$profiling_enable(pid_t pid)
{
REQUIRE_NO_PROMISES;
ScopedSpinLock lock(g_processes_lock);
auto* process = Process::from_pid(pid);
auto process = Process::from_pid(pid);
if (!process)
return -ESRCH;
if (process->is_dead())
@ -48,7 +48,7 @@ int Process::sys$profiling_enable(pid_t pid)
int Process::sys$profiling_disable(pid_t pid)
{
ScopedSpinLock lock(g_processes_lock);
auto* process = Process::from_pid(pid);
auto process = Process::from_pid(pid);
if (!process)
return -ESRCH;
if (!is_superuser() && process->uid() != m_uid)