All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: "Michael A. Halcrow" <mhalcrow@us.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] eCryptFS: mutex lock-unlock ordering fix
Date: Tue, 20 May 2008 20:42:17 +0400	[thread overview]
Message-ID: <20080520164217.GB6926@cvg> (raw)
In-Reply-To: <20080520163928.GA6926@cvg>

[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 -

      reply	other threads:[~2008-05-20 16:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-20 16:39 [PATCH] eCryptFS: mutex lock-unlock ordering fix Cyrill Gorcunov
2008-05-20 16:42 ` Cyrill Gorcunov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080520164217.GB6926@cvg \
    --to=gorcunov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhalcrow@us.ibm.com \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.