summaryrefslogtreecommitdiffstats
path: root/crypto/bio/bio_meth.c
AgeCommit message (Collapse)Author
2018-02-13Update copyright yearMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2018-02-10Copy name string in BIO_meth_newRich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5318)
2018-01-31Revert the crypto "global lock" implementationBenjamin Kaduk
Conceptually, this is a squashed version of: Revert "Address feedback" This reverts commit 75551e07bd2339dfea06ef1d31d69929e13a4495. and Revert "Add CRYPTO_thread_glock_new" This reverts commit ed6b2c7938ec6f07b15745d4183afc276e74c6dd. But there were some intervening commits that made neither revert apply cleanly, so instead do it all as one shot. The crypto global locks were an attempt to cope with the awkward POSIX semantics for pthread_atfork(); its documentation (the "RATIONALE" section) indicates that the expected usage is to have the prefork handler lock all "global" locks, and the parent and child handlers release those locks, to ensure that forking happens with a consistent (lock) state. However, the set of functions available in the child process is limited to async-signal-safe functions, and pthread_mutex_unlock() is not on the list of async-signal-safe functions! The only synchronization primitives that are async-signal-safe are the semaphore primitives, which are not really appropriate for general-purpose usage. However, the state consistency problem that the global locks were attempting to solve is not actually a serious problem, particularly for OpenSSL. That is, we can consider four cases of forking application that might use OpenSSL: (1) Single-threaded, does not call into OpenSSL in the child (e.g., the child calls exec() immediately) For this class of process, no locking is needed at all, since there is only ever a single thread of execution and the only reentrancy is due to signal handlers (which are themselves limited to async-signal-safe operation and should not be doing much work at all). (2) Single-threaded, calls into OpenSSL after fork() The application must ensure that it does not fork() with an unexpected lock held (that is, one that would get unlocked in the parent but accidentally remain locked in the child and cause deadlock). Since OpenSSL does not expose any of its internal locks to the application and the application is single-threaded, the OpenSSL internal locks will be unlocked for the fork(), and the state will be consistent. (OpenSSL will need to reseed its PRNG in the child, but that is an orthogonal issue.) If the application makes use of locks from libcrypto, proper handling for those locks is the responsibility of the application, as for any other locking primitive that is available for application programming. (3) Multi-threaded, does not call into OpenSSL after fork() As for (1), the OpenSSL state is only relevant in the parent, so no particular fork()-related handling is needed. The internal locks are relevant, but there is no interaction with the child to consider. (4) Multi-threaded, calls into OpenSSL after fork() This is the case where the pthread_atfork() hooks to ensure that all global locks are in a known state across fork() would come into play, per the above discussion. However, these "calls into OpenSSL after fork()" are still subject to the restriction to async-signal-safe functions. Since OpenSSL uses all sorts of locking and libc functions that are not on the list of safe functions (e.g., malloc()), this case is not currently usable and is unlikely to ever be usable, independently of the locking situation. So, there is no need to go through contortions to attempt to support this case in the one small area of locking interaction with fork(). In light of the above analysis (thanks @davidben and @achernya), go back to the simpler implementation that does not need to distinguish "library-global" locks or to have complicated atfork handling for locks. Reviewed-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/5089)
2017-12-15Fix invalid function type casts.Bernd Edlinger
Rename bio_info_cb to BIO_info_cb. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4493)
2017-08-31Add CRYPTO_thread_glock_newRich Salz
Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/4294)
2017-08-22Use "" not <> for internal/ includesRich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4217)
2016-11-17Add support for reference counting using C11 atomicsKurt Roeckx
Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1500
2016-10-28Fix more shadowed variable warningsMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28More parameter naming of BIO_read*/BIO_write* related functionsMatt Caswell
Based on feedback received. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Tweaks based on review feedback of BIO size_t workMatt Caswell
Rename some parameters. Also change handling of buffer sizes >INT_MAX in length. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Read up to INT_MAX when calling legacy BIO_read() implementationsMatt Caswell
In converting a new style BIO_read() call into an old one, read as much data as we can (INT_MAX), if the size of the buffer is >INT_MAX. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Create BIO_write_ex() which handles size_t argumentsMatt Caswell
Also extend BIO_METHOD to be able to supply an implementation for the new BIO_write_ex function. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Create BIO_read_ex() which handles size_t argumentsMatt Caswell
Also extend BIO_METHOD to be able to supply an implementation for the new BIO_read function. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-21Move BIO index lock creationRich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-19Add BIO_get_new_index()Rich Salz
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2016-05-17Copyright consolidation 09/10Rich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-04Don't shadow known symbols write, read, puts, getsRichard Levitte
It was harmless in this case, but best avoid the annoying warnings. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-03-29Make BIO opaqueMatt Caswell
Move the the BIO_METHOD and BIO structures into internal header files, provide appropriate accessor methods and update all internal code to use the new accessors where appropriate. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-03-29Add functions for creating BIO_METHODsMatt Caswell
BIO_METHODs are soon to be opaque so we need to have functions available to set them up. Reviewed-by: Richard Levitte <levitte@openssl.org>