Re: [v2.6.26-rc1] possible circular locking in ecryptfs

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Cyrill Gorcunov
Date: Sunday, May 18, 2008 - 8:10 am

[Ingo Molnar - Sun, May 18, 2008 at 01:40:20PM +0200]
| 
| * Cyrill Gorcunov <gorcunov@gmail.com> wrote:
| 
| > [Ingo Molnar - Fri, May 09, 2008 at 11:44:23AM +0200]
| > | 
| > | * Ingo Molnar <mingo@elte.hu> wrote:
| > | 
| > | > x86.git testing found the following "possible circular locking" 
| > | > lockdep warning, generated by the ecryptfs code:
| > | 
| > | the correct URL for the config is:
| > | 
| > |   http://redhat.com/~mingo/misc/config-Wed_May__7_16_17_31_CEST_2008.bad
| > | 
| > | this is reproducible, it happened a second time since i originally 
| > | reported it.
| > | 
| > | 	Ingo
| > 
| > Hi Ingo, I've just sent patch, could you test it, please?
| > 
| > http://lkml.org/lkml/2008/5/10/20
| 
| that patch is now upstream - but see below there's still a circular 
| dependency.
| 
| 	Ingo
| 
| 

Ingo, could you test this patch please? If it help I will send
it in normal way.

		- Cyrill -
---

Index: linux-2.6.git/fs/ecryptfs/miscdev.c
===================================================================
--- linux-2.6.git.orig/fs/ecryptfs/miscdev.c	2008-05-18 18:53:56.000000000 +0400
+++ linux-2.6.git/fs/ecryptfs/miscdev.c	2008-05-18 19:08:25.000000000 +0400
@@ -50,7 +50,6 @@ ecryptfs_miscdev_poll(struct file *file,
 					  current->nsproxy->user_ns);
 	BUG_ON(rc || !daemon);
 	mutex_lock(&daemon->mux);
-	mutex_unlock(&ecryptfs_daemon_hash_mux);
 	if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) {
 		printk(KERN_WARNING "%s: Attempt to poll on zombified "
 		       "daemon\n", __func__);
@@ -62,6 +61,7 @@ ecryptfs_miscdev_poll(struct file *file,
 		goto out_unlock_daemon;
 	daemon->flags |= ECRYPTFS_DAEMON_IN_POLL;
 	mutex_unlock(&daemon->mux);
+	mutex_unlock(&ecryptfs_daemon_hash_mux);
 	poll_wait(file, &daemon->wait, pt);
 	mutex_lock(&daemon->mux);
 	if (!list_empty(&daemon->msg_ctx_out_queue))
@@ -69,6 +69,8 @@ ecryptfs_miscdev_poll(struct file *file,
 out_unlock_daemon:
 	daemon->flags &= ~ECRYPTFS_DAEMON_IN_POLL;
 	mutex_unlock(&daemon->mux);
+	if (mutex_is_locked(&ecryptfs_daemon_hash_mux))
+		mutex_unlock(&ecryptfs_daemon_hash_mux);
 	return mask;
 }
 
@@ -257,14 +259,12 @@ ecryptfs_miscdev_read(struct file *file,
 	mutex_lock(&daemon->mux);
 	if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) {
 		rc = 0;
-		mutex_unlock(&ecryptfs_daemon_hash_mux);
 		printk(KERN_WARNING "%s: Attempt to read from zombified "
 		       "daemon\n", __func__);
 		goto out_unlock_daemon;
 	}
 	if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) {
 		rc = 0;
-		mutex_unlock(&ecryptfs_daemon_hash_mux);
 		goto out_unlock_daemon;
 	}
 	/* This daemon will not go away so long as this flag is set */
@@ -357,6 +357,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;
 }
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[v2.6.26-rc1] possible circular locking in ecryptfs, Ingo Molnar, (Wed May 7, 1:02 pm)
Re: [v2.6.26-rc1] possible circular locking in ecryptfs, Cyrill Gorcunov, (Sat May 10, 1:47 am)
Re: [v2.6.26-rc1] possible circular locking in ecryptfs, Cyrill Gorcunov, (Sun May 18, 4:46 am)
Re: [v2.6.26-rc1] possible circular locking in ecryptfs, Cyrill Gorcunov, (Sun May 18, 6:27 am)
Re: [v2.6.26-rc1] possible circular locking in ecryptfs, Cyrill Gorcunov, (Sun May 18, 8:10 am)