summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrelyea%netscape.com <devnull@localhost>2004-04-07 01:14:43 +0000
committerrelyea%netscape.com <devnull@localhost>2004-04-07 01:14:43 +0000
commit81f997497d81398146f00f8b7d0f379bb4b87b06 (patch)
tree1ad85254c4965a2938a200cb90806db75cd44146
parent842a4b6e3ad88c3a10bcd10ac82cf008ad4d309f (diff)
downloadnss-hg-81f997497d81398146f00f8b7d0f379bb4b87b06.tar.gz
Bug 239827: Fix race condition in unwrap private key code. (session keys only).
-rw-r--r--security/nss/lib/pk11wrap/pk11skey.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/security/nss/lib/pk11wrap/pk11skey.c b/security/nss/lib/pk11wrap/pk11skey.c
index e1431b3d4..f59f43187 100644
--- a/security/nss/lib/pk11wrap/pk11skey.c
+++ b/security/nss/lib/pk11wrap/pk11skey.c
@@ -5370,9 +5370,12 @@ PK11_UnwrapPrivKey(PK11SlotInfo *slot, PK11SymKey *wrappingKey,
if (newKey) {
if (perm) {
+ /* Get RW Session will either lock the monitor if necessary,
+ * or return a thread safe session handle. */
rwsession = PK11_GetRWSession(slot);
} else {
rwsession = slot->session;
+ PK11_EnterSlotMonitor(slot);
}
crv = PK11_GETTAB(slot)->C_UnwrapKey(rwsession, &mechanism,
newKey->objectID,
@@ -5380,7 +5383,11 @@ PK11_UnwrapPrivKey(PK11SlotInfo *slot, PK11SymKey *wrappingKey,
wrappedKey->len, keyTemplate,
templateCount, &privKeyID);
- if (perm) PK11_RestoreROSession(slot, rwsession);
+ if (perm) {
+ PK11_RestoreROSession(slot, rwsession);
+ } else {
+ PK11_ExitSlotMonitor(slot);
+ }
PK11_FreeSymKey(newKey);
} else {
crv = CKR_FUNCTION_NOT_SUPPORTED;