提交 d032d1b4 编写于 作者: R Riku Voipio 提交者: Aurelien Jarno

linux-user: Fix mmap_lock ordering

mmap_lock() can be called while tb_lock() is being held. To
avoid deadlock when one thread is holding mmap_lock and another
tb_lock, _always_ lock first tb_lock().
Signed-off-by: NRiku Voipio <riku.voipio@nokia.com>
Signed-off-by: NAurelien Jarno <aurelien@aurel32.net>
上级 f76cfe56
......@@ -99,13 +99,14 @@ static int pending_cpus;
/* Make sure everything is in a consistent state for calling fork(). */
void fork_start(void)
{
mmap_fork_start();
pthread_mutex_lock(&tb_lock);
pthread_mutex_lock(&exclusive_lock);
mmap_fork_start();
}
void fork_end(int child)
{
mmap_fork_end(child);
if (child) {
/* Child processes created by fork() only have a single thread.
Discard information about the parent threads. */
......@@ -122,7 +123,6 @@ void fork_end(int child)
pthread_mutex_unlock(&exclusive_lock);
pthread_mutex_unlock(&tb_lock);
}
mmap_fork_end(child);
}
/* Wait for pending exclusive operations to complete. The exclusive lock
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册