Print this page
1667 pkcs11 may deadlock when multi-threaded consumers fork

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/pkcs11/pkcs11_softtoken/common/softGeneral.c
          +++ new/usr/src/lib/pkcs11/pkcs11_softtoken/common/softGeneral.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + *
       25 + * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
  24   26   */
  25   27  
  26   28  #include <strings.h>
  27   29  #include <errno.h>
  28   30  #include <cryptoutil.h>
  29   31  #include <unistd.h> /* for pid_t */
  30   32  #include <pthread.h>
  31   33  #include <security/cryptoki.h>
  32   34  #include "softGlobal.h"
  33   35  #include "softSession.h"
↓ open down ↓ 313 lines elided ↑ open up ↑
 347  349          rv = soft_delete_all_sessions(force);
 348  350  
 349  351          (void) pthread_mutex_lock(&soft_sessionlist_mutex);
 350  352          /* Reset all_sessions_closing flag. */
 351  353          all_sessions_closing = 0;
 352  354          (void) pthread_mutex_unlock(&soft_sessionlist_mutex);
 353  355  
 354  356          softtoken_initialized = B_FALSE;
 355  357          softtoken_pid = 0;
 356  358  
 357      -        pkcs11_close_urandom();
 358      -        pkcs11_close_urandom_seed();
 359      -        pkcs11_close_random();
      359 +        /*
      360 +         * There used to be calls to cleanup libcryptoutil here.  Given that
      361 +         * libcryptoutil can be linked and invoked independently of PKCS#11,
      362 +         * cleaning up libcryptoutil here makes no sense.  Decoupling these
      363 +         * two also prevent deadlocks and other artificial dependencies.
      364 +         */
 360  365  
 361  366          /* Destroy the session list lock here */
 362  367          (void) pthread_mutex_destroy(&soft_sessionlist_mutex);
 363  368  
 364  369          /*
 365  370           * Destroy token object related stuffs
 366  371           * 1. Clean up the token object list
 367  372           * 2. Destroy slot mutex
 368  373           * 3. Destroy mutex in token_session
 369  374           */
↓ open down ↓ 165 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX