Bug 1828395

Summary: softhsm hangs in deadlock if the configuration points to non-existent path
Product: [Fedora] Fedora Reporter: Anderson Sasaki <ansasaki>
Component: softhsmAssignee: Paul Wouters <pwouters>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 33CC: abokovoy, nmavrogi, pwouters
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-12-09 14:05:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Anderson Sasaki 2020-04-27 16:25:36 UTC
Description of problem:
If the SoftHSM configuration points to a non-existent path, it hangs in deadlock at exit.

Version-Release number of selected component (if applicable):
softhsm-2.6.0-1.fc33.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Create a SoftHSM configuration file with an non-existent path. For example, containing:

directories.tokendir = XXX
objectstore.backend = file

2. Make SoftHSM to use the configuration file

$ export SOFTHSM2_CONF=config

3. run an application using libsofthsm2.so with the bad configuration. For example, using p11tool from gnutls-utils:

$ p11tool --list-tokens --provider /lib64/pkcs11/libsofthsm2.so

Actual results:

- The application hangs after printing:

pkcs11_add_provider: PKCS #11 error.


Expected results:
The application prints the error and exits instead of hanging.

Additional info:
- The same can be reproduced through pkcs11-tool from opensc:

$ pkcs11-tool --list-slots --module /lib64/pkcs11/libsofthsm2.so
error: PKCS11 function C_Initialize failed: rv = CKR_GENERAL_ERROR (0x5)
Aborting.

- An available workaround is to create the missing path pointed by the configuration file.

Comment 1 Ben Cotton 2020-08-11 13:20:56 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 33 development cycle.
Changing version to 33.

Comment 2 Paul Wouters 2020-12-09 02:02:16 UTC
Although I see no related changelog entries for 2.6.1 this does seem to have been resolved:

paul@thinkpad:~$ cat /tmp/test.conf 
directories.tokendir = XXX
objectstore.backend = file

paul@thinkpad:~$ export SOFTHSM2_CONF=/tmp/test.conf
paul@thinkpad:~$ p11tool --list-tokens --provider /lib64/pkcs11/libsofthsm2.so
pkcs11_add_provider: PKCS #11 error.

paul@thinkpad:~$ pkcs11-tool --list-slots --module /lib64/pkcs11/libsofthsm2.so
error: PKCS11 function C_Initialize failed: rv = CKR_GENERAL_ERROR (0x5)
Aborting.

It does not hang for me.

Comment 3 Anderson Sasaki 2020-12-09 08:56:53 UTC
I can't reproduce the issue with latest version (softhsm-2.6.1-3). It works as expected.