[Opendnssec-user] C_CloseAllSessions and threads
Fredrik Thulin
fredrik at thulin.net
Fri Jan 18 11:19:33 UTC 2013
Hi
There are several issues in SoftHSM when using threads and
C_CloseAllSessions.
I'm not a C++ programmer, but I believe the issue is that
C_CloseAllSessions 'delete's sessions although the sessions can be in
use in another thread - causing segmentation faults in the other thread.
The attached patch to the test suite easily demonstrates the problem on
my system. Ubuntu 12.04, SoftHSM rev 6958.
$ gdb --args ./checks -o
...
Program received signal SIGSEGV, Segmentation fault.
0x000000000040cc54 in C_GenerateRandom (hSession=<optimized out>,
pRandomData=0x7fffffffe0b0 "<snip>",
ulRandomLen=40) at ../../../src/lib/main.cpp:2756
2756 session->rng->randomize(pRandomData, ulRandomLen);
(gdb) list
2751 if(pRandomData == NULL_PTR) {
2752 DEBUG_MSG("C_GenerateRandom", "pRandomData must not be a
NULL_PTR");
2753 return CKR_ARGUMENTS_BAD;
2754 }
2755
2756 session->rng->randomize(pRandomData, ulRandomLen);
2757
2758 DEBUG_MSG("C_GenerateRandom", "OK");
2759 return CKR_OK;
2760 }
(gdb)
So session->rng is now an invalid reference since C_CloseAllSessions did
'delete' on the session from another thread.
I've seen this problem in C_GenerateKeyPair (also due to session->rng)
and in unknown place(s) crashing out in sqlite as well.
/Fredrik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: softhsm-test-pthreads.patch
Type: text/x-patch
Size: 3122 bytes
Desc: not available
URL: <http://lists.opendnssec.org/pipermail/opendnssec-user/attachments/20130118/324c2919/attachment.bin>
More information about the Opendnssec-user
mailing list