Package: softhsm2 / 2.6.1-2

Metadata

Package Version Patches format
softhsm2 2.6.1-2 3.0 (quilt)

Patch series

view the series file
Patch File delta Description
0001 Issue 548 Don t clean up engines after OpenSSL has a.patch | (download)

src/lib/crypto/OSSLCryptoFactory.cpp | 64 46 + 18 - 0 !
1 file changed, 46 insertions(+), 18 deletions(-)

 issue #548: don't clean up engines after openssl has already shut
 down
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

As of 1.1.0, OpenSSL registers its own atexit() handler to call
OPENSSL_cleanup(). If our own code subsequently tries to, for example,
unreference an ENGINE, then it'll crash or deadlock with a use after
free.

Fix it by registering a callback with OPENSSL_atexit() to be called when
OPENSSL_cleanup() is called. It sets a flag which prevents any further
touching of OpenSSL objects — which would otherwise happen fairly much
immediately thereafter when our own OSSLCryptoFactory destructor gets
called by the C++ runtime's own atexit() handler.

Fixes: #548

0002 Fix OPENSSL_cleanup detection without using our own .patch | (download)

src/lib/crypto/OSSLCryptoFactory.cpp | 40 15 + 25 - 0 !
1 file changed, 15 insertions(+), 25 deletions(-)

 fix openssl_cleanup() detection without using our own atexit()
 handler

We can't register our own atexit() or OPENSSL_atexit() handler because
there's no way to unregister it when the SoftHSM DSO is unloaded. This
causes the crash reported at https://bugzilla.redhat.com/1831086#c8

Instead of using that method to set a flag showing that OPENSSL_cleanup()
has occurred, instead test directly by calling OPENSSL_init_crypto() for
something that *would* do nothing, but will fail if OPENSSL_cleanup()
has indeed been run already.

Fixes: c2cc0652b4 "Issue #548: Don't clean up engines after OpenSSL
                   has already shut down"