summaryrefslogtreecommitdiff
path: root/crypto/threads_pthread.c
Commit message (Collapse)AuthorAgeFilesLines
* Defined out MUTEX attributes not available on NonStop SPT Threads.Randall S. Becker2021-07-021-2/+6
| | | | | | | | | | | | | | | | | Standard Posix Threads (SPT) Threads are an older separate branch of pthreads that do not support some of the capabilities in the current Posix User Threads (PUT). The change also includes a rename of the close field of OSSL_STORE_LOADER which was causing preprocessor conflicts. Fixes #15885 Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15886)
* Add assert.h to threads_pthread.c for NonStop thread compiles.Randall S. Becker2021-06-231-0/+2
| | | | | | | | | | | Fixes: #15809 Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15812)
* Always check CRYPTO_LOCK_{read,write}_lockRich Salz2021-03-141-2/+2
| | | | | | | | | | | | | | Some functions that lock things are void, so we just return early. Also make ossl_namemap_empty return 0 on error. Updated the docs, and added some code to ossl_namemap_stored() to handle the failure, and updated the tests to allow for failure. Fixes: #14230 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14238)
* Fix error-checking compiles for mutexRich Salz2021-03-121-1/+1
| | | | | | | | Fixes: #14229 Reviewed-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14264)
* Update copyright yearMatt Caswell2021-02-181-1/+1
| | | | | Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14235)
* Don't make pthreads mutexes recursive.Rich Salz2021-02-051-8/+17
| | | | | | Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13924)
* Add some more CRYPTO_atomic functionsMatt Caswell2020-12-311-1/+49
| | | | | | | We add an implementation for CRYPTO_atomic_or() and CRYPTO_atomic_load() Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/13733)
* Fix no-threadsMatt Caswell2020-12-141-15/+0
| | | | | | | | | | | | | | | | | | | Make OPENSSL_fork_prepare() et al always available even in a no-threads build. These functions are no-ops anyway so this shouldn't make any difference. This fixes an issue where the symbol_presence test fails in a no-threads build. This is because these functions have not been marked in libcrypto.num as being dependent on thread support. Enclosing the declarations of the functions in the header with an appropriate guard does not help because we never define OPENSSL_NO_THREADS (we define the opposite OPENSSL_THREADS). This confuses the scripts which only consider OPENSSL_NO_* guards. The simplest solution is to just make them always available. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13647)
* Moved OPENSSL_fork_prepare,_parent,_child from init.c to threads_pthread.c.Randall S. Becker2020-11-041-0/+21
| | | | | | | | | | | | | | | | These methods should ultimately be deprecated. The move is to insulate non-UNIX platforms from these undefined symbols. CLA: Permission is granted by the author to the OpenSSL team to use these modifications. Fixes #13273 Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13276)
* todo: remove fork protection todo comment, it isn't relevant to the FIPS ↵Pauli2020-09-281-2/+0
| | | | | | | | | provider Fixes #12984 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12997)
* NonStop port updates for 3.0.0.Randall S. Becker2020-09-121-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HPE NonStop Port Changes for 3.0.0 Includes unthreaded, PUT, and SPT for OSS. The port changes include wrapping where necessary for FLOSS and appropriate configuration changes to support that. Two tests are excluded as being inappropriate for the platform. The changes are: * Added /usr/local/include to nonstop-nsx_spt_floss to load floss.h * Added SPT Floss variant for NonStop * Wrapped FLOSS definitions in OPENSSL_TANDEM_FLOSS to allow selective enablement. * SPT build configuration for NonStop * Skip tests not relevant for NonStop * PUT configuration changes required for NonStop platforms * Configurations/50-nonstop.conf: updates for TNS/X platform. * FLOSS instrumentation for HPE NonStop TNS/X and TNS/E platforms. * Configurations/50-nonstop.conf: modifications for non-PUT TNS/E platform b * Fix use of DELAY in ssltestlib.c for HPNS. * Fixed commit merge issues and added floss to http_server.c CLA: Permission is granted by the author to the OpenSSL team to use these modifications. Fixes #5087. Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12800)
* Update copyright yearMatt Caswell2020-05-151-1/+1
| | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11839)
* Rename FIPS_MODE to FIPS_MODULERichard Levitte2020-04-281-2/+2
| | | | | | | | | | This macro is used to determine if certain pieces of code should become part of the FIPS module or not. The old name was confusing. Fixes #11538 Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/11539)
* drbg: ensure fork-safety without using a pthread_atfork handlerDr. Matthias St. Pierre2019-09-111-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | When the new OpenSSL CSPRNG was introduced in version 1.1.1, it was announced in the release notes that it would be fork-safe, which the old CSPRNG hadn't been. The fork-safety was implemented using a fork count, which was incremented by a pthread_atfork handler. Initially, this handler was enabled by default. Unfortunately, the default behaviour had to be changed for other reasons in commit b5319bdbd095, so the new OpenSSL CSPRNG failed to keep its promise. This commit restores the fork-safety using a different approach. It replaces the fork count by a fork id, which coincides with the process id on UNIX-like operating systems and is zero on other operating systems. It is used to detect when an automatic reseed after a fork is necessary. To prevent a future regression, it also adds a test to verify that the child reseeds after fork. CVE-2019-1549 Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9832)
* use native atomic increment function on SolarisVladimir Kotal2019-08-091-0/+10
| | | | | | Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9215)
* Make core code available within the FIPS moduleMatt Caswell2019-05-231-4/+8
| | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8728)
* Following the license change, modify the boilerplates in crypto/Richard Levitte2018-12-061-1/+1
| | | | | | | [skip ci] Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7827)
* crypto/threads_*: remove CRYPTO_atomic_{read|write}.Andy Polyakov2018-08-171-38/+0
| | | | | | | | | | CRYPTO_atomic_read was added with intention to read statistics counters, but readings are effectively indistinguishable from regular load (even in non-lock-free case). This is because you can get out-dated value in both cases. CRYPTO_atomic_write was added for symmetry and was never used. Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from https://github.com/openssl/openssl/pull/6883)
* Update copyright yearRichard Levitte2018-04-171-1/+1
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5990)
* Set error code if alloc returns NULLRich Salz2018-04-051-4/+10
| | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5886)
* Return a value from atomic read on Windows.Pauli2017-10-111-1/+1
| | | | | | | Use a read lock when reading using pthreads. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4517)
* Add atomic write callPauli2017-10-101-0/+19
| | | | | Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4414)
* Add a CRYPTO_atomic_read call which allows an int variable to be readPauli2017-10-101-0/+19
| | | | | | | in an atomic fashion. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4414)
* Put thread-fork-init inside a run-once guardRich Salz2017-08-181-2/+11
| | | | | | | Thanks to Christian Heimes for pointing this out. Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4191)
* Add missing include of cryptlib.hRich Salz2017-08-061-1/+1
| | | | | | | Also use "" not <> for all include cryptlib Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4082)
* Add fork handlers, based on pthread_atforkRich Salz2017-06-291-0/+10
| | | | | | | Only for Unix platforms Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3754)
* Grouped data declarations [skip ci]Dmitry Kostjuchenko2017-02-031-1/+0
| | | | | Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1981)
* Removed tab spaces.Dmitry Kostjuchenko2017-02-031-2/+2
| | | | | Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1981)
* Corrections according the review comments.Dmitry Kostjuchenko2017-02-031-21/+22
| | | | | | Updated indentations according project rules, renamed file-local define to the shorter version - USE_RWLOCK, fixed declaration after the if statement in CRYPTO_THREAD_lock_new(). Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1981)
* Compile fix on platforms with missing pthread_rwlock_t.Dmitry Kostjuchenko2017-02-031-0/+41
| | | | | | | | | | Fix compilation on platforms with missing pthread_rwlock_t implementation by replacing it with pthread_mutex_t. An example of such platform can be Android OS 2.0 - 2.1, API level 5 (Eclair), Android NDK platform - android-5 where pthread_rwlock_t is not implemented and is missing in pthread.h. In case of missing pthread_rwlock_t implementation CRYPTO_RWLOCK will work as exclusive lock in write-only mode of pthread_rwlock_t lock. The implementation based on pthread_mutex_t must be using PTHREAD_MUTEX_RECURSIVE mode to be compatible with recursive behavior of pthread_rwlock_rdlock. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1981)
* CRYPTO_atomic_add(): check that the object is lock freeRichard Levitte2016-08-241-3/+5
| | | | | | If not, fall back to our own code, using the given mutex Reviewed-by: Andy Polyakov <appro@openssl.org>
* CRYPTO_atomic_add(): use acquire release memory order rather than relaxedRichard Levitte2016-08-241-2/+2
| | | | | | | | For increments, the relaxed model is fine. For decrements, it's recommended to use the acquire release model. We therefore go for the latter. Reviewed-by: Andy Polyakov <appro@openssl.org>
* Check for __GNUC__ to use GNU C atomic buildinsRichard Levitte2016-08-241-3/+3
| | | | | | | | | Note: we trust any other compiler that fully implements GNU extension to define __GNUC__ RT#4642 Reviewed-by: Andy Polyakov <appro@openssl.org>
* Copyright consolidation 09/10Rich Salz2016-05-171-46/+6
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* Fold threads.h into crypto.h making API publicViktor Dukhovni2016-05-161-1/+0
| | | | | | Document thread-safe lock creation Reviewed-by: Richard Levitte <levitte@openssl.org>
* GH773: Possible leak on CRYPTO_THREAD_lock_new failureFdaSilvaYY2016-03-031-1/+3
| | | | | Signed-off-by: Rich Salz <rsalz@akamai.com> Reviewed-by: Matt Caswell <matt@openssl.org>
* Implement new multi-threading APIAlessandro Ghedini2016-02-261-0/+167
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>