diff options
author | Andreas Kling <awesomekling@gmail.com> | 2020-01-12 18:46:41 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-12 19:04:16 +0100 |
commit | 41376d46620710d4fc148b3eb3a2f4a12189c795 (patch) | |
tree | 74b562d4825f06dd1c09df227cfe726aea7a2300 /Kernel/Thread.h | |
parent | 61e6b1fb7c2770a2b5b56cbff5217adf8c2c4ee8 (diff) | |
download | serenity-41376d46620710d4fc148b3eb3a2f4a12189c795.zip |
Kernel: Fix Lock racing to the WaitQueue
There was a time window between releasing Lock::m_lock and calling into
the lock's WaitQueue where someone else could take m_lock and bring two
threads into a deadlock situation.
Fix this issue by holding Lock::m_lock until interrupts are disabled by
either Thread::wait_on() or WaitQueue::wake_one().
Diffstat (limited to 'Kernel/Thread.h')
-rw-r--r-- | Kernel/Thread.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Kernel/Thread.h b/Kernel/Thread.h index c17b43bbba..18f8546464 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -1,5 +1,6 @@ #pragma once +#include <AK/Atomic.h> #include <AK/Function.h> #include <AK/IntrusiveList.h> #include <AK/OwnPtr.h> @@ -300,7 +301,7 @@ public: return block<ConditionBlocker>(state_string, move(condition)); } - void wait_on(WaitQueue& queue, Thread* beneficiary = nullptr, const char* reason = nullptr); + void wait_on(WaitQueue& queue, Atomic<bool>* lock = nullptr, Thread* beneficiary = nullptr, const char* reason = nullptr); void wake_from_queue(); void unblock(); |