summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjulien.pierre.bugs%sun.com <devnull@localhost>2004-12-08 01:25:14 +0000
committerjulien.pierre.bugs%sun.com <devnull@localhost>2004-12-08 01:25:14 +0000
commit93d00309841000806f4f8bc04fcd3fd4b045d0ae (patch)
tree83398845349fd27e47397173056f2b2481fcc32f
parentc56a31a6bd8c411f50c2012655d0d405f5eb6ad3 (diff)
downloadnss-hg-93d00309841000806f4f8bc04fcd3fd4b045d0ae.tar.gz
Fix for 270689 - race condition in softoken list lock creation . r=nelson
-rw-r--r--security/nss/lib/softoken/pkcs11.c3
-rw-r--r--security/nss/lib/softoken/pkcs11i.h1
-rw-r--r--security/nss/lib/softoken/pkcs11u.c20
3 files changed, 20 insertions, 4 deletions
diff --git a/security/nss/lib/softoken/pkcs11.c b/security/nss/lib/softoken/pkcs11.c
index 31a5f3aec..d134ffca1 100644
--- a/security/nss/lib/softoken/pkcs11.c
+++ b/security/nss/lib/softoken/pkcs11.c
@@ -2822,6 +2822,9 @@ CK_RV nsc_CommonInitialize(CK_VOID_PTR pReserved, PRBool isFIPS)
loser:
secmod_freeParams(&paramStrings);
}
+ if (CKR_OK == crv) {
+ pk11_InitFreeLists();
+ }
return crv;
}
diff --git a/security/nss/lib/softoken/pkcs11i.h b/security/nss/lib/softoken/pkcs11i.h
index 0f382f8ba..eb9f8dfb2 100644
--- a/security/nss/lib/softoken/pkcs11i.h
+++ b/security/nss/lib/softoken/pkcs11i.h
@@ -637,6 +637,7 @@ extern PK11Session *pk11_NewSession(CK_SLOT_ID slotID, CK_NOTIFY notify,
extern void pk11_update_state(PK11Slot *slot,PK11Session *session);
extern void pk11_update_all_states(PK11Slot *slot);
extern void pk11_FreeContext(PK11SessionContext *context);
+extern void pk11_InitFreeLists(void);
extern void pk11_CleanupFreeLists(void);
extern NSSLOWKEYPublicKey *pk11_GetPubKey(PK11Object *object,
diff --git a/security/nss/lib/softoken/pkcs11u.c b/security/nss/lib/softoken/pkcs11u.c
index 235fb92d8..ada8b9665 100644
--- a/security/nss/lib/softoken/pkcs11u.c
+++ b/security/nss/lib/softoken/pkcs11u.c
@@ -2088,10 +2088,6 @@ pk11_GetObjectFromList(PRBool *hasLocks, PRBool optimizeSpace,
int size = 0;
if (!optimizeSpace) {
- if (list->lock == NULL) {
- list->lock = PZ_NewLock(nssILockObject);
- }
-
PK11_USE_THREADS(PZ_Lock(list->lock));
object = list->head;
if (object) {
@@ -2154,6 +2150,22 @@ pk11_freeObjectData(PK11Object *object) {
PORT_Free(object);
return next;
}
+
+static void
+pk11_InitFreeList(PK11ObjectFreeList *list)
+{
+#ifdef PKCS11_USE_THREADS
+ list->lock = PZ_NewLock(nssILockObject);
+#else
+ list->lock = NULL;
+#endif
+}
+
+void pk11_InitFreeLists(void)
+{
+ pk11_InitFreeList(&sessionObjectList);
+ pk11_InitFreeList(&tokenObjectList);
+}
static void
pk11_CleanupFreeList(PK11ObjectFreeList *list, PRBool isSessionList)