[Cyrill Gorcunov - Tue, May 20, 2008 at 08:39:28PM +0400]
| We should lock/unlock mutexes by a proper way which means
| there should not be chains like ABAB but ABBA otherwise the
| race window is opened.
|
| Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
| CC: Michael A. Halcrow <mhalcrow@us.ibm.com>
| ---
|
| check_list:
[...]
| if (list_empty(&daemon->msg_ctx_out_queue)) {
NIT ---> | + if (mutex_is_locked(&ecryptfs_daemon_hash_mux))
| + mutex_unlock(&ecryptfs_daemon_hash_mux);
| mutex_unlock(&daemon->mux);
| - rc = wait_event_interruptible(
| - daemon->wait, !list_empty(&daemon->msg_ctx_out_queue));
| + rc = wait_event_interruptible(daemon->wait,
| + !list_empty(&daemon->msg_ctx_out_queue));
| mutex_lock(&daemon->mux);
| if (rc < 0) {
| rc = 0;
| @@ -357,6 +358,8 @@ out_unlock_msg_ctx:
| out_unlock_daemon:
| daemon->flags &= ~ECRYPTFS_DAEMON_IN_READ;
| mutex_unlock(&daemon->mux);
| + if (mutex_is_locked(&ecryptfs_daemon_hash_mux))
| + mutex_unlock(&ecryptfs_daemon_hash_mux);
| return rc;
| }
|
It's a bit wrong (could release mutex being ack'ed by another thread)
will fix - please DROP this patch. Sorry!
- Cyrill -
--