mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-24 00:24:38 +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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user