[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20080520164217.GB6926@cvg>
Date: Tue, 20 May 2008 20:42:17 +0400
From: Cyrill Gorcunov <gorcunov@...il.com>
To: "Michael A. Halcrow" <mhalcrow@...ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...e.hu>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] eCryptFS: mutex lock-unlock ordering fix
[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@...il.com>
| CC: Michael A. Halcrow <mhalcrow@...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 -
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists