From 41376d46620710d4fc148b3eb3a2f4a12189c795 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 12 Jan 2020 18:46:41 +0100 Subject: 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(). --- Kernel/Thread.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Kernel/Thread.h') 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 #include #include #include @@ -300,7 +301,7 @@ public: return block(state_string, move(condition)); } - void wait_on(WaitQueue& queue, Thread* beneficiary = nullptr, const char* reason = nullptr); + void wait_on(WaitQueue& queue, Atomic* lock = nullptr, Thread* beneficiary = nullptr, const char* reason = nullptr); void wake_from_queue(); void unblock(); -- cgit v1.2.3