mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 20:12:13 +00:00
Kernel: Scheduler donations need to verify that the beneficiary is valid.
Add a Thread::is_thread(void*) helper that we can use to check that the incoming donation beneficiary is a valid thread. The O(n) here is a bit sad and we should eventually rethink the process/thread table data structures.
This commit is contained in:
parent
6bb0dbe8bf
commit
c59f8cd663
3 changed files with 19 additions and 5 deletions
|
@ -526,3 +526,13 @@ Vector<Thread*> Thread::all_threads()
|
|||
threads.append(thread);
|
||||
return threads;
|
||||
}
|
||||
|
||||
bool Thread::is_thread(void* ptr)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
for (auto* thread = g_threads->head(); thread; thread = thread->next()) {
|
||||
if (thread == ptr)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue