Messages in this thread Patch in this message | | | Date | Mon, 14 Apr 2008 01:03:28 +0530 (IST) | From | Arun Raghavan <> | Subject | [PATCH] [keys] Use mutex instead of rw_semaphore for __key_link() serialisation |
| |
__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;
| |