* [PATCH] [keys] Use mutex instead of rw_semaphore for __key_link() serialisation
@ 2008-04-13 19:33 Arun Raghavan
2008-04-14 10:23 ` David Howells
0 siblings, 1 reply; 2+ messages in thread
From: Arun Raghavan @ 2008-04-13 19:33 UTC (permalink / raw)
To: dhowells, linux-kernel; +Cc: satyam
__key_link() uses an rw_semaphore as a mutex to serialise link/link calls.
This patch converts it to explicitly use a struct mutex.
Signed-off-by: Arun Raghavan <arunsr@cse.iitk.ac.in>
Signed-off-by: Satyam Sharma <satyam@infradead.org>
---
security/keys/keyring.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 5f31eb7..7bfc725 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/security.h>
#include <linux/seq_file.h>
+#include <linux/mutex.h>
#include <linux/err.h>
#include <asm/uaccess.h>
#include "internal.h"
@@ -69,10 +70,10 @@ struct key_type key_type_keyring = {
EXPORT_SYMBOL(key_type_keyring);
/*
- * semaphore to serialise link/link calls to prevent two link calls in parallel
+ * mutex to serialise link/link calls to prevent two link calls in parallel
* introducing a cycle
*/
-static DECLARE_RWSEM(keyring_serialise_link_sem);
+static DEFINE_MUTEX(keyring_serialise_link_mutex);
/*****************************************************************************/
/*
@@ -681,7 +682,7 @@ int __key_link(struct key *keyring, struct key *key)
/* serialise link/link calls to prevent parallel calls causing a
* cycle when applied to two keyring in opposite orders */
- down_write(&keyring_serialise_link_sem);
+ mutex_lock(&keyring_serialise_link_mutex);
/* check that we aren't going to create a cycle adding one keyring to
* another */
@@ -789,7 +790,7 @@ int __key_link(struct key *keyring, struct key *key)
done:
ret = 0;
error2:
- up_write(&keyring_serialise_link_sem);
+ mutex_unlock(&keyring_serialise_link_mutex);
error:
return ret;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] [keys] Use mutex instead of rw_semaphore for __key_link() serialisation
2008-04-13 19:33 [PATCH] [keys] Use mutex instead of rw_semaphore for __key_link() serialisation Arun Raghavan
@ 2008-04-14 10:23 ` David Howells
0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2008-04-14 10:23 UTC (permalink / raw)
To: Arun Raghavan; +Cc: dhowells, linux-kernel, satyam
Arun Raghavan <arunsr@cse.iitk.ac.in> wrote:
> __key_link() uses an rw_semaphore as a mutex to serialise link/link calls.
> This patch converts it to explicitly use a struct mutex.
>
> Signed-off-by: Arun Raghavan <arunsr@cse.iitk.ac.in>
> Signed-off-by: Satyam Sharma <satyam@infradead.org>
Acked-by: David Howells <dhowells@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-14 10:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-13 19:33 [PATCH] [keys] Use mutex instead of rw_semaphore for __key_link() serialisation Arun Raghavan
2008-04-14 10:23 ` David Howells
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).