OpenSolaris

Printable Version Enter a New Search
Bug ID 6522116
Synopsis handle2session() routines can be improved in pkcs11 libraries
State 10-Fix Delivered (Fix available in build)
Category:Subcategory solaris-crypto:pkcs11
Keywords ef-reviewed
Responsible Engineer Bhargava Yenduri
Reported Against
Duplicate Of
Introduced In solaris_10
Commit to Fix snv_85
Fixed In snv_85
Release Fixed solaris_nevada(snv_85) , solaris_10u6(s10u6_02) (Bug ID:2161657)
Related Bugs 6604363
Submit Date 7-February-2007
Last Update Date 12-March-2008
Description
meta_handle2session() has the following code -
   124          /* Lock to ensure the magic-check + read-lock is atomic. */
   125          (void) pthread_rwlock_rdlock(&meta_sessionclose_lock);
   126
   127          if (tmp_session->magic_marker != METASLOT_SESSION_MAGIC) {
   128                  (void) pthread_rwlock_unlock(&meta_sessionclose_lock);
   129                  *session = NULL;
   130                  return (CKR_SESSION_HANDLE_INVALID);
   131          }
   132          (void) pthread_rwlock_unlock(&meta_sessionclose_lock);


The meta_sessionclose_lock offers no protection because it is dropped on line 132. We can check the magic_marker without holding the lock and check it again under the protection of tmp_session->session_lock. The thread that is setting
	session->magic_marker = METASLOT_SESSION_BADMAGIC;
in meta_session_deactivate() is holding the session_lock. So, this is safe to do.
Looking at the other libraries ...
handle2_session() routine in pkcs11_softtoken library can be improved. It is needlessly holding soft_sessionlist_mutex. handle2_session() routine in pkcs11_kernel can be improved. It is needlessly holding the slot lock.
Moved to evaluation.
Work Around
N/A
Comments
N/A