lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 14 Apr 2008 01:03:28 +0530 (IST)
From:	Arun Raghavan <arunsr@....iitk.ac.in>
To:	dhowells@...hat.com, linux-kernel@...r.kernel.org
cc:	satyam@...radead.org
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@....iitk.ac.in>
Signed-off-by: Satyam Sharma <satyam@...radead.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;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ