* [PATCH] eCryptFS: fix missed mutex_unlock
@ 2008-05-18 14:26 Cyrill Gorcunov
2008-05-20 7:28 ` Andrew Morton
2008-05-21 8:02 ` Ingo Molnar
0 siblings, 2 replies; 5+ messages in thread
From: Cyrill Gorcunov @ 2008-05-18 14:26 UTC (permalink / raw)
To: Michael A. Halcrow; +Cc: Andrew Morton, Ingo Molnar, LKML
---
Ingo, could you please apply it and test? Actually I really doubt if it help
with the locking problem you pointed. There are two procedures
in miscrev.c - ecryptfs_miscdev_poll() and ecryptfs_miscdev_read()
which takes/releases mutexes in a bit strange way... investigating,
but this patch is needed anyway.
Index: linux-2.6.git/fs/ecryptfs/crypto.c
===================================================================
--- linux-2.6.git.orig/fs/ecryptfs/crypto.c 2008-05-18 16:44:20.000000000 +0400
+++ linux-2.6.git/fs/ecryptfs/crypto.c 2008-05-18 17:56:12.000000000 +0400
@@ -1903,6 +1903,7 @@ int ecryptfs_get_tfm_and_mutex_for_ciphe
if (rc) {
printk(KERN_ERR "Error adding new key_tfm to list; "
"rc = [%d]\n", rc);
+ mutex_unlock(&key_tfm_list_mutex);
goto out;
}
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] eCryptFS: fix missed mutex_unlock
2008-05-18 14:26 [PATCH] eCryptFS: fix missed mutex_unlock Cyrill Gorcunov
@ 2008-05-20 7:28 ` Andrew Morton
2008-05-20 9:46 ` Cyrill Gorcunov
2008-05-21 8:02 ` Ingo Molnar
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2008-05-20 7:28 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: Michael A. Halcrow, Ingo Molnar, LKML
On Sun, 18 May 2008 18:26:11 +0400 Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> ---
>
> Ingo, could you please apply it and test? Actually I really doubt if it help
> with the locking problem you pointed. There are two procedures
> in miscrev.c - ecryptfs_miscdev_poll() and ecryptfs_miscdev_read()
> which takes/releases mutexes in a bit strange way... investigating,
> but this patch is needed anyway.
>
> Index: linux-2.6.git/fs/ecryptfs/crypto.c
> ===================================================================
> --- linux-2.6.git.orig/fs/ecryptfs/crypto.c 2008-05-18 16:44:20.000000000 +0400
> +++ linux-2.6.git/fs/ecryptfs/crypto.c 2008-05-18 17:56:12.000000000 +0400
> @@ -1903,6 +1903,7 @@ int ecryptfs_get_tfm_and_mutex_for_ciphe
> if (rc) {
> printk(KERN_ERR "Error adding new key_tfm to list; "
> "rc = [%d]\n", rc);
> + mutex_unlock(&key_tfm_list_mutex);
> goto out;
> }
> }
Better to do it this way, I think:
--- a/fs/ecryptfs/crypto.c~ecryptfs-fix-missed-mutex_unlock
+++ a/fs/ecryptfs/crypto.c
@@ -1906,9 +1906,9 @@ int ecryptfs_get_tfm_and_mutex_for_ciphe
goto out;
}
}
- mutex_unlock(&key_tfm_list_mutex);
(*tfm) = key_tfm->key_tfm;
(*tfm_mutex) = &key_tfm->key_tfm_mutex;
out:
+ mutex_unlock(&key_tfm_list_mutex);
return rc;
}
_
Holding the lock for an additional few instructions may not be strictly
needed, but we might avoid the reintroduction of such bugs?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] eCryptFS: fix missed mutex_unlock
2008-05-20 7:28 ` Andrew Morton
@ 2008-05-20 9:46 ` Cyrill Gorcunov
0 siblings, 0 replies; 5+ messages in thread
From: Cyrill Gorcunov @ 2008-05-20 9:46 UTC (permalink / raw)
To: Andrew Morton; +Cc: Michael A. Halcrow, Ingo Molnar, LKML
On Tue, May 20, 2008 at 11:28 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Sun, 18 May 2008 18:26:11 +0400 Cyrill Gorcunov <gorcunov@gmail.com> wrote:
>
>> ---
>>
>> Ingo, could you please apply it and test? Actually I really doubt if it help
>> with the locking problem you pointed. There are two procedures
>> in miscrev.c - ecryptfs_miscdev_poll() and ecryptfs_miscdev_read()
>> which takes/releases mutexes in a bit strange way... investigating,
>> but this patch is needed anyway.
>>
>> Index: linux-2.6.git/fs/ecryptfs/crypto.c
>> ===================================================================
>> --- linux-2.6.git.orig/fs/ecryptfs/crypto.c 2008-05-18 16:44:20.000000000 +0400
>> +++ linux-2.6.git/fs/ecryptfs/crypto.c 2008-05-18 17:56:12.000000000 +0400
>> @@ -1903,6 +1903,7 @@ int ecryptfs_get_tfm_and_mutex_for_ciphe
>> if (rc) {
>> printk(KERN_ERR "Error adding new key_tfm to list; "
>> "rc = [%d]\n", rc);
>> + mutex_unlock(&key_tfm_list_mutex);
>> goto out;
>> }
>> }
>
> Better to do it this way, I think:
>
> --- a/fs/ecryptfs/crypto.c~ecryptfs-fix-missed-mutex_unlock
> +++ a/fs/ecryptfs/crypto.c
> @@ -1906,9 +1906,9 @@ int ecryptfs_get_tfm_and_mutex_for_ciphe
> goto out;
> }
> }
> - mutex_unlock(&key_tfm_list_mutex);
> (*tfm) = key_tfm->key_tfm;
> (*tfm_mutex) = &key_tfm->key_tfm_mutex;
> out:
> + mutex_unlock(&key_tfm_list_mutex);
> return rc;
> }
> _
>
> Holding the lock for an additional few instructions may not be strictly
> needed, but we might avoid the reintroduction of such bugs?
>
>
Good idea, thanks! Could you update the patch, please?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] eCryptFS: fix missed mutex_unlock
2008-05-18 14:26 [PATCH] eCryptFS: fix missed mutex_unlock Cyrill Gorcunov
2008-05-20 7:28 ` Andrew Morton
@ 2008-05-21 8:02 ` Ingo Molnar
2008-05-21 9:33 ` Cyrill Gorcunov
1 sibling, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2008-05-21 8:02 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: Michael A. Halcrow, Andrew Morton, LKML
* Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> Ingo, could you please apply it and test? Actually I really doubt if
> it help with the locking problem you pointed. There are two procedures
> in miscrev.c - ecryptfs_miscdev_poll() and ecryptfs_miscdev_read()
> which takes/releases mutexes in a bit strange way... investigating,
> but this patch is needed anyway.
btw., i didnt do any specific ecryptfs testing - randconfig enabled it
and it got booted. So if you dont get the warning during
bootup/module-load, you'll have the same test coverage i did.
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] eCryptFS: fix missed mutex_unlock
2008-05-21 8:02 ` Ingo Molnar
@ 2008-05-21 9:33 ` Cyrill Gorcunov
0 siblings, 0 replies; 5+ messages in thread
From: Cyrill Gorcunov @ 2008-05-21 9:33 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Michael A. Halcrow, Andrew Morton, LKML
On Wed, May 21, 2008 at 12:02 PM, Ingo Molnar <mingo@elte.hu> wrote:
>
> * Cyrill Gorcunov <gorcunov@gmail.com> wrote:
>
>> Ingo, could you please apply it and test? Actually I really doubt if
>> it help with the locking problem you pointed. There are two procedures
>> in miscrev.c - ecryptfs_miscdev_poll() and ecryptfs_miscdev_read()
>> which takes/releases mutexes in a bit strange way... investigating,
>> but this patch is needed anyway.
>
> btw., i didnt do any specific ecryptfs testing - randconfig enabled it
> and it got booted. So if you dont get the warning during
> bootup/module-load, you'll have the same test coverage i did.
>
> Ingo
>
oh, thanks ;)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-05-21 9:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-18 14:26 [PATCH] eCryptFS: fix missed mutex_unlock Cyrill Gorcunov
2008-05-20 7:28 ` Andrew Morton
2008-05-20 9:46 ` Cyrill Gorcunov
2008-05-21 8:02 ` Ingo Molnar
2008-05-21 9:33 ` Cyrill Gorcunov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).