From: Doug E. <no...@gi...> - 2021-01-26 11:51:14
|
Branch: refs/heads/master Home: https://github.com/OpenSC/OpenSC Commit: 1b4e9f1d4aea2ac1c29b821505e4c03872e46650 https://github.com/OpenSC/OpenSC/commit/1b4e9f1d4aea2ac1c29b821505e4c03872e46650 Author: Doug Engert <dee...@gm...> Date: 2021-01-26 (Tue, 26 Jan 2021) Changed paths: M src/pkcs11/pkcs11-global.c Log Message: ----------- C_Initialize may be called by multiple threads While trying to setup an OpenSC context, the global_locking and detect cards, it is possible that multiple threads may call C_Initialize. The current code tries to prevent this using "if (context == NULL)" but this is not a mutex, and multiple threads may endup overwrite contexts and global locking and cause additional problems, with pcsc and segfault. FireFox appears to do this see #2032 The PR adds a mutex or Critical section to make sure only one thread creates the context sets the global_locking and does the initial detect cards, etc. This allows the global_lock (if requested) to be setup which is then used for other calls. All but the first call to C_Initialize will return with CKR_OK, others will return CKR_CRYPTOKI_ALREADY_INITIALIZED. Date: Mon Jan 11 12:47:12 2021 -0600 Changes to be committed: modified: src/pkcs11/pkcs11-global.c Commit: f704e4f23e1c3b8accd1bfb11cf1dfc5dce3ffe6 https://github.com/OpenSC/OpenSC/commit/f704e4f23e1c3b8accd1bfb11cf1dfc5dce3ffe6 Author: Doug Engert <dee...@gm...> Date: 2021-01-26 (Tue, 26 Jan 2021) Changed paths: M doc/tools/pkcs11-tool.1.xml M src/tools/Makefile.am M src/tools/pkcs11-tool.c Log Message: ----------- Pkcs11-tool changes to test a modules ability to use threads Option --use-locking has C_Initialize pass in parameters with the CKF_OS_LOCKING_OK to tell module to use threads. The default is it passes NULL which says threads are not needed. The following is not designed to be used by the general user. There are for debugging and test scripts and only compiled if the system has threads. Option --test-threads <arg> can be passed multiple times. Each one starts a thread. <arg> is a list of 2 byte commands seperated by ":". The thread will execute these. Current commands are: IN - C_Initialize(NULL) IL - C_Initialize with CKF_OS_LOCKING_OK Pn - Pause for n seconds GI - C_GetInfo SL - C_GetSlotList Tn - C_GetTokenInfo from slot_index n These are just enough calls to see if threads are working in the module. Output is written to stderr. Changes to be committed: modified: doc/tools/pkcs11-tool.1.xml modified: src/tools/Makefile.am modified: src/tools/pkcs11-tool.c Commit: b5ddaf6e021ecda74f35784a46eb874fb22e4019 https://github.com/OpenSC/OpenSC/commit/b5ddaf6e021ecda74f35784a46eb874fb22e4019 Author: Doug Engert <dee...@gm...> Date: 2021-01-26 (Tue, 26 Jan 2021) Changed paths: M tests/Makefile.am A tests/test-pkcs11-tool-test-threads.sh Log Message: ----------- Add tests of pkcs11-tool --test-threads These should run when a PR is submitted. Changes to be committed: modified: tests/Makefile.am new file: tests/test-pkcs11-tool-test-threads.sh Compare: https://github.com/OpenSC/OpenSC/compare/d369965a7fd2...b5ddaf6e021e |