summaryrefslogtreecommitdiffstats
path: root/crypto/bio
AgeCommit message (Collapse)Author
2023-07-01bio: update to structure based atomicsPauli
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21260)
2023-03-07bss_dgram.c: Use BIO_ADDR_sockaddr() and BIO_ADDR_sockaddr_size()Richard Levitte
Especially, it's important to use BIO_ADDR_sockaddr_size() instead of taking sizeof(addr), as BIO_ADDR is a union of several sockaddr variants with different sizes, and some sendto() implementations are very picky that the size is correct for the indicated sockaddr family. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20449)
2023-02-22Ensure calling BIO_recvmmsg() with a dgram pair reports errorsMatt Caswell
When calling BIO-recvmmsg() and using a dgram pair we were failing to raise an error in the case that a problem occurs. This means that the reason behind a failure cannot be detected and all problems are treated as fatal even if they may not be. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20030)
2023-02-22Don't raise an error on retryable read in a BIO_s_dgram_pair()Matt Caswell
This results in spurious errors appearing on the queue in normal operation, e.g. calling SSL_tick() with a QUIC connection will succeed, but an error will end up on the queue anyway. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20030)
2023-02-08Fix incomplete BIO_dup_state() error checkndossche
BIO_dup_state() returns an error code <= 0 according to my analysis tool and the documentation. Currently only == 0 is checked. Fix it by changing the check condition. CLA: trivial Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> (Merged from https://github.com/openssl/openssl/pull/20194)
2023-02-08Fix incomplete error check on BIO_set_accept_name()ndossche
BIO_set_accept_name() can return error values -1 and 0 according to my analysis tool and the documentation. Documentation says a value of 1 indicates success. Currently, only an error value != 0 is checked which erroneously interprets a -1 error return value as success. Fix it by changing the check condition. CLA: trivial Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> (Merged from https://github.com/openssl/openssl/pull/20206)
2023-01-27Implement BIO_s_dgram_mem() reusing the BIO_s_dgram_pair() codeTomas Mraz
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20012)
2023-01-27Revert "Give BIO_s_mem() the ability to support datagrams"Tomas Mraz
This reverts commit 5a4ba72f00f9b336a4d65abff822699ceb9617c6. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20012)
2023-01-13Add BIO poll descriptorsHugo Landau
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19703)
2022-12-05Fix the check of BIO_set_write_buffer_size and BIO_set_read_buffer_sizePeiwei Hu
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19819)
2022-11-24Add support for KTLS zerocopy sendfile on LinuxMaxim Mikityanskiy
TLS device offload allows to perform zerocopy sendfile transmissions. FreeBSD provides this feature by default, and Linux 5.19 introduced it as an opt-in. Zerocopy improves the TX rate significantly, but has a side effect: if the underlying file is changed while being transmitted, and a TCP retransmission happens, the receiver may get a TLS record containing both new and old data, which leads to an authentication failure and termination of connection. This effect is the reason Linux makes a copy on sendfile by default. This commit adds support for TLS zerocopy sendfile on Linux disabled by default to avoid any unlikely backward compatibility issues on Linux, although sacrificing consistency in OpenSSL's behavior on Linux and FreeBSD. A new option called KTLSTxZerocopySendfile is added to enable the new zerocopy behavior on Linux. This option should be used when the the application guarantees that the file is not modified during transmission, or it doesn't care about breaking the connection. The related documentation is also added in this commit. The unit test added doesn't test the actual functionality (it would require specific hardware and a non-local peer), but solely checks that it's possible to set the new option flag. Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Reviewed-by: Boris Pismenny <borisp@nvidia.com> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18650)
2022-11-14djgpp: Fix unused-but-set-variable warningJ.W. Jagersma
I chose to just hide this behind '#ifndef __DJGPP__', instead of listing all the macro combinations where it *is* used. That would make quite a mess. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19322)
2022-11-14Cast socklen_t to size_t in assert comparisonJ.W. Jagersma
This causes a warning otherwise when socklen_t is signed (Watt32). Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19322)
2022-10-12crypto/*: Fix various typos, repeated words, align some spelling to LDP.FdaSilvaYY
partially revamped from #16712 - fall thru -> fall through - time stamp -> timestamp - host name -> hostname - ipv6 -> IPv6 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19059)
2022-10-12crypto: Fix various typos, repeated words, align some spelling to LDP.FdaSilvaYY
partially revamped from #16712 - fall thru -> fall through - time stamp -> timestamp - file name -> filename - host name -> hostname Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19059)
2022-10-06Rename ossl_sleep calls to OSSL_sleep everywhereRichard Levitte
Also, remove inclusions of internal/e_os.h where it seems no longer necessary. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/19330)
2022-10-05Stop raising ERR_R_MALLOC_FAILURE in most placesRichard Levitte
Since OPENSSL_malloc() and friends report ERR_R_MALLOC_FAILURE, and at least handle the file name and line number they are called from, there's no need to report ERR_R_MALLOC_FAILURE where they are called directly, or when SSLfatal() and RLAYERfatal() is used, the reason `ERR_R_MALLOC_FAILURE` is changed to `ERR_R_CRYPTO_LIB`. There were a number of places where `ERR_R_MALLOC_FAILURE` was reported even though it was a function from a different sub-system that was called. Those places are changed to report ERR_R_{lib}_LIB, where {lib} is the name of that sub-system. Some of them are tricky to get right, as we have a lot of functions that belong in the ASN1 sub-system, and all the `sk_` calls or from the CRYPTO sub-system. Some extra adaptation was necessary where there were custom OPENSSL_malloc() wrappers, and some bugs are fixed alongside these changes. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19301)
2022-09-30ERR: replace remnant ECerr() and EVPerr() calls in crypto/Dr. David von Oheimb
except those throwing ERR_R_MALLOC_FAILURE Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/19302)
2022-09-27dgram_pair_read_inner(): Do not move buf pointer if it is NULLTomas Mraz
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19284)
2022-09-27A static const variable is implicitly zero initializedTomas Mraz
Older clang versions complain about the explicit initializer because the first member of the struct is a struct. But it is not necessary to explicitly initialize it anyway. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19284)
2022-09-23Maximum return value of BIO_ctrl_(w)pending is SIZE_MAXTomas Mraz
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19240)
2022-09-23Fix error return values from BIO_ctrl_(w)pending()Tomas Mraz
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19240)
2022-09-23BIO_s_dgram_pairHugo Landau
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18442)
2022-09-13libcrypto: remove reliance on struct timevalPauli
Reviewed-by: Todd Short <todd.short@me.com> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19082)
2022-09-09Remove perror() usage in libraryTodd Short
The dgram code used perror extensively. Keep the `perror()` in the allocation code; it's used for debugging only. Keep the `perror()`s in the demos, tests and apps. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19148)
2022-09-08Fix BIO_sendmmsg/BIO_recvmmsg issues on FreeBSDHugo Landau
Fixes #19156. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19164)
2022-09-08Fix undefined ipi_spec_dst for cygwin build.Tristan Lelong
The 'struct in_pktinfo' doesn't have a 'ipi_spec_dst' field on windows OS which break cygwin builds of OpenSSL. Signed-off-by: Tristan Lelong <tlelong@google.com> Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19134)
2022-09-07Fix build failure on freebsd due to missing data declarationTomas Mraz
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19130)
2022-09-02QUIC Demuxer and Record Layer (RX Side)Hugo Landau
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18949)
2022-09-01BIO_dgram support for BIO_sendmmsg/BIO_recvmmsgHugo Landau
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18270)
2022-08-19BIO_sendmmsg/BIO_recvmmsg (API only)Hugo Landau
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18923)
2022-08-12Fix asan finding in bio_addrJuergen Christ
Running test_tfo_cli under asan yields ==166214==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60700000d57c at pc 0x03ffa004ed86 bp 0x03ffe2977e80 sp 0x03ffe2977668 READ of size 112 at 0x60700000d57c thread T0 #0 0x3ffa004ed85 in memcpy (/lib64/libasan.so.8+0x4ed85) #1 0x3ff9f3615b7 in BIO_ADDR_dup crypto/bio/bio_addr.c:77 [...] and fails the test. Fix this by copying the right structure of the union. Signed-off-by: Juergen Christ <jchrist@linux.ibm.com> Reviewed-by: Todd Short <todd.short@me.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18979)
2022-07-28Give BIO_s_mem() the ability to support datagramsMatt Caswell
We introduce a new BIO ctrl that switches a BIO_s_mem() into datagram mode. Packet boundaries are respected. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18596)
2022-07-17Coverity 1506566: unchecked return valuePauli
There isn't much else that can be done here unfortunately. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18799)
2022-07-08Add config option OPENSSL_NO_UNIX_SOCKMax Bachmann
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18256)
2022-06-29Avoid using union wrt. SystemTimeToFileTimeTee KOBAYASHI
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18660)
2022-06-29Avoid using union wrt. optlen parameter for getsockoptTee KOBAYASHI
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18660)
2022-05-27Don't include sys/select.h on HP-UX as it doesn't existTom Hughes
CLA: trivial Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18395)
2022-05-17Fix KTLS with BIO_new_connectBernd Edlinger
When a socket connection is done using BIO_new_connect, the ktls_enable is done too early, and fails with ENOTCONN. Therefore the KLTS ioctl will fail later with ENOPROTOOPT. Fix that by doing the ktls_enable after the connection succeeded, not when the socket is created as that will always fail. One example where this happens is doit_localhost in test/ssl_old_test.c, and therefore, contrary to the expectation the -client_ktls option did never enable the client KTLS connection, but this was not noticed, because there was no diagnostic output, and it was only visible with strace output. Also enhanced the ssl_old_test -client_ktls/-server_ktls options together with -v option to print a summary line if and how KTLS was negotiated in server and client. While I am already there adjusted the usage info of the -s_cert, -s_key commands, and allow -time to print the timings of ktls connections. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18318)
2022-05-09Exclude IPv6 code using OPENSSL_USE_IPV6 instead of AF_INET6Max Bachmann
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18250)
2022-05-03Update copyright yearMatt Caswell
Reviewed-by: Tomas Mraz <tomas@openssl.org> Release: yes
2022-04-01Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATAHugo Landau
This refactors OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA. The assorted objects to be managed by OSSL_LIB_CTX are hardcoded and are initialized eagerly rather than lazily, which avoids the need for locking on access in most cases. Fixes #17116. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17881)
2022-03-10Add TFO support to socket BIO and s_client/s_serverTodd Short
Supports Linux, MacOS and FreeBSD Disabled by default, enabled via `enabled-tfo` Some tests Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8692)
2022-02-05Move e_os.h to include/internalRichard Levitte
Including e_os.h with a path from a header file doesn't work well on certain exotic platform. It simply fails to build. Since we don't seem to be able to stop ourselves, the better move is to move e_os.h to an include directory that's part of the inclusion path given to the compiler. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17641)
2022-02-04Fix builds with DJGPPJuan Manuel Guerrero
CLA: trivial To get the master branch compiled with DJGPP some minor adjustments are required. They will have no impact on any other ports. The DJGPP port uses the Watt-32 library to provide the required network functionality and some of its headers need to be included. Neither DJGPP nor the Watt-32 library provide in_addr_t thus it must be provided as it is done for OPENSSL_SYS_WINDOWS in crypto/bio/b_addr.c. In the DJGPP section of include/internal/sockets.h the following Watt-32 headers must be added: - arpa/inet.h: to provide declaration of inet_ntoa required in crypto/bio/b_addr.c - netinet/tcp.h: to provide defintion of TCP_NODELAY required in crypto/bio/b_sock2.c Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17623)
2022-01-27BIO_new_from_core_bio: Check for NULL pointer after calling get_globalsJiasheng Jiang
The get_globals could return NULL, for example, CRYPTO_THREAD_read_lock() failed. Therefore, just checking the member of 'bcgbl' is not enough. We need to check 'bcgbl' itself too in order to avoid the dereference of the NULL pointer. And the caller of ossl_bio_init_core(), OSSL_LIB_CTX_new_from_dispatch() in `crypto/context.c`, has already checked return value and dealed with the situation if it returns 0. Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17581)
2022-01-21crypto/bio: drop float formating for UEFIGerd Hoffmann
Using floating point is not supported in UEFI and can cause build problems, for example due to SSE being disabled and x64 calling convention passing floats in SSE registers. Avoid those problems by not compiling the formating code for floating point numbers. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17547)
2022-01-21Revert "crypto/bio: fix build on UEFI"Gerd Hoffmann
This reverts commit 328bf5adf9e23da523d4195db309083aa02403c4. Turned out it isn't that simple, the fix is incomplete. So revert and try again with another approach. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17547)
2022-01-09crypto/bio: fix build on UEFIGerd Hoffmann
When compiling openssl for tianocore compiling abs_val() and pow_10() fails with the following error because SSE support is disabled: crypto/bio/bio_print.c:587:46: error: SSE register return with SSE disabled Fix that by using EFIAPI calling convention when compiling for UEFI. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17442)
2021-11-15BIO_s_connect(): Enable BIO_gets()Dr. David von Oheimb
Fixes #16028 Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16030)