]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
6 months ago80-test_cmp_http.t: on test failures print Mock server STDERR output
Dr. David von Oheimb [Wed, 29 Jan 2025 17:59:49 +0000 (18:59 +0100)] 
80-test_cmp_http.t: on test failures print Mock server STDERR output

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26589)

(cherry picked from commit e7c6c5e0885b797c67a363802072fd1df2c54558)

6 months ago80-test_cmp_http_data/Mock/test.cnf: further relax total_timeout as workaround for...
Dr. David von Oheimb [Wed, 29 Jan 2025 07:18:40 +0000 (08:18 +0100)] 
80-test_cmp_http_data/Mock/test.cnf: further relax total_timeout as workaround for heavily loaded test systems

Fixes #26577

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26584)

(cherry picked from commit 12baad7ed47fce8977929cec4eafa0912bab8756)

6 months agoOpen pem files in binary mode
Josh Cooper [Wed, 16 Oct 2024 22:06:16 +0000 (15:06 -0700)] 
Open pem files in binary mode

In order to avoid an MSVCRT bug affecting ftell and text mode[1], open PEM files
in binary mode. The PEM parser already handles CRLF translation[2].

[1] https://github.com/openssl/openssl/commit/8300a8742b2abc487594a09b5e6ee726dbd30771
[2] https://github.com/openssl/openssl/pull/24249#issuecomment-2192025429

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25716)

(cherry picked from commit 4f20de0c8adc9cdcd1475155d467f66980915ab3)

6 months agoRevert "Work around Windows ftell() bug as per Microsoft engineering's suggestion"
Josh Cooper [Wed, 16 Oct 2024 19:24:03 +0000 (12:24 -0700)] 
Revert "Work around Windows ftell() bug as per Microsoft engineering's suggestion"

This reverts commit 8300a8742b2abc487594a09b5e6ee726dbd30771.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25716)

(cherry picked from commit ed3ce7545797e2c7202a6fcbf83c8bba3ead460d)

6 months agoFix passing struct by value rather than by reference to syscall
Mae [Wed, 22 Jan 2025 16:54:43 +0000 (16:54 +0000)] 
Fix passing struct by value rather than by reference to syscall

Fixes #26521

CLA: trivial

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26523)

(cherry picked from commit b6f2ff93639d9c71aae62dfc72082dd0829c2170)

6 months agoFix data race in asn1_str2tag() on tntmp which was accidentally made static
Stas Cymbalov [Tue, 21 Jan 2025 13:42:19 +0000 (16:42 +0300)] 
Fix data race in asn1_str2tag() on tntmp which was accidentally made static

Variables tntmp and tnst are declared in the same declaration and thus
share storage class specifiers (static). This is unfortunate as tntmp is
used during iteration through tnst array and shouldn't be static.
In particular this leads to two problems that may arise when multiple
threads are executing asn1_str2tag() concurrently:
1. asn1_str2tag() might return value that doesn't correspond to tagstr
   parameter. This can happen if other thread modifies tntmp to point to
   a different tnst element right after a successful name check in the
   if statement.
2. asn1_str2tag() might perform an out-of-bounds read of tnst array.
   This can happen when multiple threads all first execute tntmp = tnst;
   line and then start executing the loop. If that case those threads
   can end up incrementing tntmp past the end of tnst array.

CLA: trivial

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26504)

(cherry picked from commit 7262c0bcc468ab8e43ba96ca219acdb4667e45e0)

6 months agoeddsa_signverify_init(): Avoid memory leak on error
Tomas Mraz [Tue, 21 Jan 2025 13:42:28 +0000 (14:42 +0100)] 
eddsa_signverify_init(): Avoid memory leak on error

Add missing WPACKET_cleanup() call.
Fixes Coverity 1638693

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/26500)

(cherry picked from commit abbc4073145cb6b2ea221f3e34809e9aefece9ab)

6 months agomac_legacy_kmgmt.c: Avoid possible memory leak on error
Tomas Mraz [Tue, 21 Jan 2025 13:38:23 +0000 (14:38 +0100)] 
mac_legacy_kmgmt.c: Avoid possible memory leak on error

Use mac_gen_cleanup() instead of just freeing the gctx.
Fixes Coverity 1638702

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/26500)

(cherry picked from commit 2455ef2112997d6a366623a209f1d0090ed2d847)

6 months agotest_kdf_scrypt(): Test resetting the KDF context
Tomas Mraz [Mon, 20 Jan 2025 08:16:30 +0000 (09:16 +0100)] 
test_kdf_scrypt(): Test resetting the KDF context

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/26488)

(cherry picked from commit 4f7d2b48093fd5147c652da319e43baea61a6218)

6 months agokdf_scrypt_reset(): NULLify freed pointers
Tomas Mraz [Mon, 20 Jan 2025 07:53:21 +0000 (08:53 +0100)] 
kdf_scrypt_reset(): NULLify freed pointers

Otherwise doublefree happens with further usage.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/26488)

(cherry picked from commit 901b108154fd8d28516b9b4bebde93ac5bc2a224)

6 months agoscrypt: Do not free the context itself when fetch fails
Tomas Mraz [Mon, 20 Jan 2025 07:50:48 +0000 (08:50 +0100)] 
scrypt: Do not free the context itself when fetch fails

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/26488)

(cherry picked from commit 2dded720223c6b84dcbeadbbcd1c6307fe815832)

6 months agoconfig.pod: Fix typo
Alexander Heinlein [Tue, 21 Jan 2025 07:34:53 +0000 (08:34 +0100)] 
config.pod: Fix typo

CLA: trivial

Signed-off-by: Alexander Heinlein <alexander.heinlein@web.de>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26497)

(cherry picked from commit b07a273f59bd8a1738d86dca8720d0d11b6c8bd0)

6 months agoGive DTLS tests more time to complete
Bernd Edlinger [Tue, 21 Jan 2025 15:12:18 +0000 (16:12 +0100)] 
Give DTLS tests more time to complete

Increase the timeout for DTLS tests to 10 seconds.
But do that only for DTLS as this would waste time
for other tests, most of the TLS tests do not need
this at all.

Fixes #26491

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26502)

(cherry picked from commit b999ea6bc43ef6c53d464f364b7799ac9049ddd9)

6 months agorcu: Ensure that updates to the ID field of a qp don't lose refs
Neil Horman [Sun, 19 Jan 2025 21:43:37 +0000 (16:43 -0500)] 
rcu: Ensure that updates to the ID field of a qp don't lose refs

ppc64le occasionally still fails the threadstest on __rcu_torture

From several days of debugging, I think I've landed on the problem.

Occasionally, under high load I observe the following pattern

CPU0                                     CPU1
update_qp                                get_hold_current_qp
  atomic_and_fetch(qp->users, ID_MASK, RELEASE)
                                         atomic_add_fetch(qp->users, 1, RELEASE
  atomic_or_fetch(qp->users, ID_VAL++, RELEASE)

When this pattern occurs, the atomic or operation fails to see the published
value of CPU1 and when the or-ed value is written back to ram, the incremented
value in get_hold_current_qp is overwritten, meaning the hold that the reader
placed on the rcu lock is lost, allowing the writer to complete early, freeing
memory before a reader is done reading any held memory.

Why this is only observed on ppc64le I'm not sure, but it seems like a pretty
clear problem.

fix it by implementing ATOMIC_COMPARE_EXCHANGE_N, so that, on the write side in
update_qp, we can ensure that updates are only done if the read side hasn't
changed anything.  If it has, retry the operation.

With this fix, I'm able to run the threads test overnight (4000 iterations and
counting) without failure.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26478)

(cherry picked from commit fbd34c03e3ca94d3805e97a01defdf8b6037f61c)

6 months agoImprove ASN1_TIME_print documentation and output
Michael Baentsch [Wed, 8 Jan 2025 11:57:28 +0000 (12:57 +0100)] 
Improve ASN1_TIME_print documentation and output

This adds missing GMT indication when printing the local time as
it is converted to the UTC timezone before printing.

Also fixing the fractional seconds printing on EBCDIC platforms.

Fixes #26313

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26344)

(cherry picked from commit c81ff978667e7c0d792e02db7a02b7bc12433abd)

6 months agos_socket: naccept: close listening socket after accepting clients
Nadav Tasher [Fri, 20 Dec 2024 15:59:01 +0000 (17:59 +0200)] 
s_socket: naccept: close listening socket after accepting clients

When `-naccept` is passed (i.e with `s_server`), the listening socket remains open while handling
client, even after `naccept` is supposed to reach `0`.

This is caused to to the decrementation of `naccept` and closing of the socket
happening a little too late in the `do_server` function.

Signed-off-by: Nadav Tasher <tashernadav@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26228)

(cherry picked from commit 113c12ee8cee2be232a361da277a2ab48807eeed)

6 months agoRestore correct registers in aarch64 AES-CTR code
Julian Andres Klode [Sat, 18 Jan 2025 20:12:45 +0000 (21:12 +0100)] 
Restore correct registers in aarch64 AES-CTR code

Commit 1d1ca79fe35dbe5c05faed5a2ef8c4de9c5adc49 introduced
save and restore for the registers, saving them as

stp d8,d9,[sp, #16]
stp d10,d11,[sp, #32]
stp d12,d13,[sp, #48]
stp d14,d15,[sp, #64]

But the restore code was inadvertently typoed:

ldp d8,d9,[sp, #16]
ldp d10,d11,[sp, #32]
ldp d12,d13,[sp, #48]
ldp d15,d16,[sp, #64]

Restoring [sp, #64] into d15,d16 instead of d14,d15.

Fixes: #26466
CLA: trivial

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26469)

(cherry picked from commit 5261f3ca41cda7ad5767e399e9a2dc008bbad5d6)

6 months agoAdd CHANGES.md and NEWS.md updates for CVE-2024-13176
Tomas Mraz [Wed, 15 Jan 2025 17:29:52 +0000 (18:29 +0100)] 
Add CHANGES.md and NEWS.md updates for CVE-2024-13176

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26429)

(cherry picked from commit c3144e102571517df6c15ccc049fa3660ab3cb0a)

6 months agoFix timing side-channel in ECDSA signature computation
Tomas Mraz [Wed, 15 Jan 2025 17:27:02 +0000 (18:27 +0100)] 
Fix timing side-channel in ECDSA signature computation

There is a timing signal of around 300 nanoseconds when the top word of
the inverted ECDSA nonce value is zero. This can happen with significant
probability only for some of the supported elliptic curves. In particular
the NIST P-521 curve is affected. To be able to measure this leak, the
attacker process must either be located in the same physical computer or
must have a very fast network connection with low latency.

Attacks on ECDSA nonce are also known as Minerva attack.

Fixes CVE-2024-13176

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26429)

(cherry picked from commit 63c40a66c5dc287485705d06122d3a6e74a6a203)

6 months agoIf you call X509_add_cert with cert == NULL and the X509_ADD_FLAG_UP_REF
otherddn1978 [Thu, 26 Dec 2024 10:26:34 +0000 (13:26 +0300)] 
If you call X509_add_cert with cert == NULL and the X509_ADD_FLAG_UP_REF
flag, it will сrash to X509_up_ref.  Passing NULL here is not valid,
return 0 if cert == NULL.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26267)

(cherry picked from commit 3c7db9e0fdf4706d91cedf5fca70b609bdc1677e)

6 months agoFix documentation of OSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION
Richard Levitte [Wed, 15 Jan 2025 09:14:41 +0000 (10:14 +0100)] 
Fix documentation of OSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION

This drops OSSL_PKEY_PARAM_IMPLICIT_REJECTION - which is a meaningless
name - everywhere apart from still existing (for API stability, in
case someone uses that macro).

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26421)

(cherry picked from commit 1df07c761b25e5aca8ecd90b81d05496631285fb)

6 months agoWorkaround for RSA on AArch64 Big Endian
Nikolay Nikolaev [Tue, 24 Dec 2024 11:26:09 +0000 (13:26 +0200)] 
Workaround for RSA on AArch64 Big Endian

10646160125 introduced and optimized RSA NEON implementation
for AArch64 architecture, namely Cortex-A72 and Neoverse N1.
This implementation is broken in Big Endian mode, which is not
widely used, therefore not properly verified.
Here we disable this optimized implementation when Big Endian
platform is used.

Fixes: #22687
CLA: trivial

Signed-off-by: Nikolay Nikolaev <nicknickolaev@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26257)

(cherry picked from commit b26894ec6945656113fd9556527765aba08e4355)

6 months agoRemove non-existing error code.
Peter Bierma [Sun, 12 Jan 2025 16:12:18 +0000 (11:12 -0500)] 
Remove non-existing error code.

CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26389)

(cherry picked from commit 0b1d3ebb70a13917cf28ed934150c29819d95997)

6 months agoSynchronize openssl.txt with comperr.h
Peter Bierma [Sat, 11 Jan 2025 17:02:45 +0000 (12:02 -0500)] 
Synchronize openssl.txt with comperr.h

CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26389)

(cherry picked from commit 5b81f942d5011fbb05d0dc7016af05161b3ba010)

6 months agoFix dtls tests
Bernd Edlinger [Fri, 10 Jan 2025 07:45:20 +0000 (08:45 +0100)] 
Fix dtls tests

The dtls server process exits too early when the input
has an EOF condition.

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26374)

(cherry picked from commit 52bcf4f88be949ecedfc924bc8ef37cbed7f24fb)

6 months agoRevert "Use open2 instead of open for s_server instance"
Bernd Edlinger [Thu, 9 Jan 2025 20:26:12 +0000 (21:26 +0100)] 
Revert "Use open2 instead of open for s_server instance"

This reverts commit 4439ed16c5742e5ffb0417d45677900e77b299f2.

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26374)

(cherry picked from commit bf2e6e849dbec5755c63d1c8b253365c3173a525)

6 months agoRevert "chomp does not work on windows."
Bernd Edlinger [Thu, 9 Jan 2025 20:25:55 +0000 (21:25 +0100)] 
Revert "chomp does not work on windows."

This reverts commit 3e94e2b11d73ed22c601f818b31b7c4ca281f5d1.

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26374)

(cherry picked from commit 716a64fcc4b0981fd788deb43ca6548cc634ea56)

6 months agoRevert "Do not confuse TAP::Parser by mixing up stderr with stdout."
Bernd Edlinger [Thu, 9 Jan 2025 20:24:44 +0000 (21:24 +0100)] 
Revert "Do not confuse TAP::Parser by mixing up stderr with stdout."

This reverts commit 3d3bb26a13dcc67f99e66de6a44ae9ced117f64b.

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26374)

(cherry picked from commit 824d23772b2c38bdeab60ccb087517e62e5192e5)

6 months agoCorrect documented KEM ids for OSSL_HPKE_str2suite
Tom Fay [Thu, 12 Dec 2024 09:38:54 +0000 (09:38 +0000)] 
Correct documented KEM ids for OSSL_HPKE_str2suite

CLA: trivial

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26159)

(cherry picked from commit 62f9fd832ad8ddbeb6b835ef513e87c563256da2)

6 months agoFix test failure in 30-test_evp_pkey_provided.t
Bernd Edlinger [Fri, 10 Jan 2025 18:58:46 +0000 (19:58 +0100)] 
Fix test failure in 30-test_evp_pkey_provided.t

In this test there is a random test output corruption.
`make test TESTS=test_evp_pkey_provided V=1` has some random output,
that can with a certain probability start a line with "ok" or so:

    # Setting up a OSSL_ENCODER context with passphrase
    # Testing with no encryption
jLixONcRPi/m64CGie4KKKDuGeTjtYwfima3BNYCGlgbLGeK3yYxBfZb9JjviOJ4
    # nHaNsRsONTAKyg==

This happens because large random data is output to bio_out
but some data remains buffered, and then test_note() is used to print
some comments on the bio_err file.  This causes output corruption that
confuses the TAP parser.
Fix that by flushing any pending output with test_flush_stdout() first.

Fixes #23992

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26383)

(cherry picked from commit c37f564bb8e25f825ff722642aaf735e8d74abb4)

6 months agoFix obvious misspelling of ASN1_VALUE
Tom Cosgrove [Tue, 10 Dec 2024 11:31:11 +0000 (11:31 +0000)] 
Fix obvious misspelling of ASN1_VALUE

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26118)

(cherry picked from commit 4188ab2b198a5c9f302e15c5e08c3c095389b6e5)

6 months agoFix double 'the's
Tom Cosgrove [Thu, 5 Dec 2024 09:08:42 +0000 (09:08 +0000)] 
Fix double 'the's

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26118)

(cherry picked from commit 690bb5192c7ef36f427dddf9719b938d76837b23)

6 months agoLoongArch: we should access global symbol by la.global instead of
Wang Xin [Wed, 8 Jan 2025 01:18:47 +0000 (01:18 +0000)] 
LoongArch: we should access global symbol by la.global instead of
la.pcrel

openssl will not be built successfully with binutils-2.43.50.20241230
which checks if global symbols are accessed by PC-relative in shared
library.

CLA: trivial

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26336)

(cherry picked from commit dd7a79fc6fe2169612a7000c9b765b3e1d6f06bb)

6 months agoFix premature reuse of qp's in rcu locks
Neil Horman [Fri, 10 Jan 2025 19:37:28 +0000 (14:37 -0500)] 
Fix premature reuse of qp's in rcu locks

An intermittent failure was noted on our new ppc64le CI runner, in which
what appeared to be a corrupted or invalid value getting returned from a
shared pointer under rcu protection

Investigation showed that the problem was with our small number of qp's
in a lock, and slightly incorrect accounting of the number of qp's
available we were prematurely recycling qp's, which led in turn to
premature completion of synchronization states, resulting in readers
reading memory that may have already been freed.

Fix it by:
a) Ensuring that we account for the fact that the first qp in an rcu
lock is allocated at the time the lock is created

and

b) Ensuring that we have a minimum number of 3 qp's:
1 that is free for write side allocation
1 that is in use by the write side currently
1 "next" qp that the read side can update while the prior qp is being
retired

With this change, the rcu threadstest runs indefinately in my testing

Fixes #26356

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26384)

(cherry picked from commit 25f8e2c15b701514b7b2fe652634289b6fb8581f)

6 months agoFix intermittent test failure in 80-test_cmp_http.t
Bernd Edlinger [Thu, 9 Jan 2025 14:14:15 +0000 (15:14 +0100)] 
Fix intermittent test failure in 80-test_cmp_http.t

output to stderr is unbuffered bypassing the normal output, which does
not happen at line boundaries and is therefore confusing the TAP parser.
This is known to cause random test failures like this one:

80-test_cmp_http.t                    (Wstat: 0 Tests: 5 Failed: 0)
  Parse errors: Tests out of sequence.  Found (6) but expected (5)
                Bad plan.  You planned 6 tests but ran 5.

Fixes #23992

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26363)

(cherry picked from commit 37a954e5c39d94c5aa60cb694071c3ee82610997)

6 months agospeed: Pass IV to EVP_CipherInit_ex for -evp runs with non-AEAD ciphers
Ingo Franzki [Wed, 8 Jan 2025 15:00:33 +0000 (16:00 +0100)] 
speed: Pass IV to EVP_CipherInit_ex for -evp runs with non-AEAD ciphers

Some (non-AEAD) ciphers require an IV to be used. Always pass a (dummy) IV
when setting the key. It is ignored by ciphers that do not use an IV.

Commit 607a46d003f472d4bce646f3df6e85725094d68a corrected the use of AEAD
ciphers, but removed the IV from being passed to EVP_CipherInit_ex() for
non-AEAD ciphers.

Fixes: https://github.com/openssl/openssl/commit/607a46d003f472d4bce646f3df6e85725094d68a
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26346)

(cherry picked from commit b8028d489037033a6eaa02b11755e5be0e688523)

6 months agoupdate tlsfuzzer to new version
Alicja Kario [Thu, 29 Aug 2024 17:39:10 +0000 (19:39 +0200)] 
update tlsfuzzer to new version

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26377)

6 months agoFix buildinf.h generation for space and backslash
Kai Pastor [Sat, 4 Jan 2025 10:48:26 +0000 (11:48 +0100)] 
Fix buildinf.h generation for space and backslash

Builds may be configured with CC or CFLAGS containing space and
double quotes. In particular on Windows, this may lead to passing
more than two arguments into mkbuildinf.pl.
In addition, backslashes must be escaped for constructing the C string.

Fixes #26253.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26315)

(cherry picked from commit e87a3473fd1e9d901a89d4b14a53826723357701)

6 months agoUpdate error codes in "crypto/err/openssl.txt"
Michael Baentsch [Tue, 7 Jan 2025 09:30:56 +0000 (10:30 +0100)] 
Update error codes in "crypto/err/openssl.txt"

Fixes #26316

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26330)

(cherry picked from commit 3cfcf820bd667d0b0253dacda5af533c99f5631d)

6 months agoReplace self-hosted runners with GitHub hosted
Dmitry Misharov [Thu, 2 Jan 2025 14:32:41 +0000 (15:32 +0100)] 
Replace self-hosted runners with GitHub hosted

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26304)

(cherry picked from commit ea71f8cd40358bf11f2ef9a256bf99c5929379fb)

6 months agoFix memory leaks from missing checks of return value from sk_OPENSSL_STRING_push()
Frederik Wedel-Heinen [Sat, 21 Dec 2024 20:15:36 +0000 (21:15 +0100)] 
Fix memory leaks from missing checks of return value from sk_OPENSSL_STRING_push()

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26238)

(cherry picked from commit d48874ab477be0fa3df11bfcc38c043b8f7ab8e2)

6 months agoFix the use of OPENSSL_HTTP_PROXY / OPENSSL_HTTPS_PROXY
Richard Levitte [Wed, 8 Jan 2025 09:15:02 +0000 (10:15 +0100)] 
Fix the use of OPENSSL_HTTP_PROXY / OPENSSL_HTTPS_PROXY

Fixes #26337

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26340)

(cherry picked from commit 6a2472fb3e958c029989286d9272bd2b23738f85)

6 months agoFree data if sk_OPENSSL_STRING_push fails.
Frederik Wedel-Heinen [Fri, 20 Dec 2024 14:45:53 +0000 (15:45 +0100)] 
Free data if sk_OPENSSL_STRING_push fails.

Fixes #26203

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26227)

(cherry picked from commit 2457fc4816551a7e982117a4032fd1c259c493a7)

6 months agoReturn NULL from ossl_lib_ctx_get_concrete() when it is uninitialized
Frederik Wedel-Heinen [Sun, 5 Jan 2025 19:42:51 +0000 (20:42 +0100)] 
Return NULL from ossl_lib_ctx_get_concrete() when it is uninitialized

When default_context_inited is set to false we return NULL instead of
the global default context.

Fixes #25442

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26319)

(cherry picked from commit dfce0d7418d6d5b54d74fa80fc50392f00270c53)

6 months agoFix potential memory leak in PKCS12_add_key_ex()
Niels Dossche [Mon, 28 Oct 2024 16:04:03 +0000 (17:04 +0100)] 
Fix potential memory leak in PKCS12_add_key_ex()

p8 is allocated using EVP_PKEY2PKCS8(), but when PKCS8_add_keyusage()
fails this memory is not freed. Fix this by adding a call to
PKCS8_PRIV_KEY_INFO_free().

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25818)

(cherry picked from commit f822a4866894ed8a752ad93c228fb76a8bb206e8)

6 months agoFix a potential misaligned memory access
Bernd Edlinger [Thu, 2 Jan 2025 15:17:46 +0000 (16:17 +0100)] 
Fix a potential misaligned memory access

in test/wpackettest.c:593:18: runtime error: load of misaligned address
for type 'uint64_t', which requires 8 byte alignment.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26269)

(cherry picked from commit 94f95efce93555f65d3582558e39866e9f074ca2)

6 months agoRun fuzz-checker workflow on ubuntu-24.04
Bernd Edlinger [Thu, 26 Dec 2024 15:30:16 +0000 (16:30 +0100)] 
Run fuzz-checker workflow on ubuntu-24.04

Fix missing afl++-clang package
Use clang-18
Configure ubsan with -fno-sanitize=function

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26269)

(cherry picked from commit c45fddd5975797dab656849968fa010c2207a722)

6 months agoFix test failure in 90-test_memleak.t
Bernd Edlinger [Fri, 27 Dec 2024 22:02:47 +0000 (23:02 +0100)] 
Fix test failure in 90-test_memleak.t

recent gcc versions can optimize the memory leak away,
avoid that by declaring the lost variable to be volatile.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26269)

(cherry picked from commit eeb3266ebba6d70df31f20e4ebd46065fc917ce5)

6 months agouse-of-uninitialized-value in quic_tserver_test
Bernd Edlinger [Fri, 27 Dec 2024 12:56:06 +0000 (13:56 +0100)] 
use-of-uninitialized-value in quic_tserver_test

Fixes #26277

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26269)

(cherry picked from commit 9861be4eef925ec1751765f8138ad81e0632234f)

6 months agoFix a minor memory sanitizer issue
Bernd Edlinger [Thu, 26 Dec 2024 10:56:17 +0000 (11:56 +0100)] 
Fix a minor memory sanitizer issue

Here the undefined value "npa" passed to a function
WPACKET_sub_memcpy_u16(pkt, npa, npalen).
However the value is not really used, because "npalen" is zero,
but the call statememt itself is considered an invalid operation
by the new sanitizer.

The original sanitizer error report was:

==49175==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55a276b29d6f in tls_construct_stoc_next_proto_neg /home/runner/work/openssl/openssl/ssl/statem/extensions_srvr.c:1518:21
    #1 0x55a276b15d7d in tls_construct_extensions /home/runner/work/openssl/openssl/ssl/statem/extensions.c:909:15
    #2 0x55a276b513dc in tls_construct_server_hello /home/runner/work/openssl/openssl/ssl/statem/statem_srvr.c:2471:10
    #3 0x55a276b2e160 in write_state_machine /home/runner/work/openssl/openssl/ssl/statem/statem.c:896:26
    #4 0x55a276b2e160 in state_machine /home/runner/work/openssl/openssl/ssl/statem/statem.c:490:21
    #5 0x55a276b2f562 in ossl_statem_accept /home/runner/work/openssl/openssl/ssl/statem/statem.c:309:12
    #6 0x55a276a9f867 in SSL_do_handshake /home/runner/work/openssl/openssl/ssl/ssl_lib.c:4890:19
    #7 0x55a276a9f605 in SSL_accept /home/runner/work/openssl/openssl/ssl/ssl_lib.c:2169:12
    #8 0x55a276a3d4db in create_bare_ssl_connection /home/runner/work/openssl/openssl/test/helpers/ssltestlib.c:1281:24
    #9 0x55a276a3d7cb in create_ssl_connection /home/runner/work/openssl/openssl/test/helpers/ssltestlib.c:1350:10
    #10 0x55a276a64c0b in test_npn /home/runner/work/openssl/openssl/test/sslapitest.c:12266:14
    #11 0x55a276b9fc20 in run_tests /home/runner/work/openssl/openssl/test/testutil/driver.c:377:21
    #12 0x55a276ba0b10 in main /home/runner/work/openssl/openssl/test/testutil/main.c:31:15

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26269)

(cherry picked from commit e63e889b32a3503a992ed0d0d2d1138e06be0209)

6 months agoTry to work around the llvm-symbolizer failure
Bernd Edlinger [Fri, 27 Dec 2024 07:49:13 +0000 (08:49 +0100)] 
Try to work around the llvm-symbolizer failure

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26269)

(cherry picked from commit 01e657c5468a637959395b07b385e58785c486f2)

6 months agoAdd __isoc23_strtol to unix-symbols.txt
Bernd Edlinger [Thu, 26 Dec 2024 20:02:58 +0000 (21:02 +0100)] 
Add __isoc23_strtol to unix-symbols.txt

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26269)

(cherry picked from commit ada0265aab7f6e24547d6fb2b1035e2dfd5a4cff)

6 months agoAdd -fno-sanitize=function to ubsan
Bernd Edlinger [Wed, 16 Oct 2024 14:37:32 +0000 (16:37 +0200)] 
Add -fno-sanitize=function to ubsan

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26269)

(cherry picked from commit 5f0dab5e74b7cdb1b51217044966dc3927824a4d)

6 months agoClean up ASN1_STRING comment and improve example in docs
Job Snijders [Tue, 17 Dec 2024 13:05:49 +0000 (13:05 +0000)] 
Clean up ASN1_STRING comment and improve example in docs

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26195)

(cherry picked from commit 2e36bb07b50a1dc55f97aeccbec9fbc5048290d1)

6 months ago80-test_cms.t: Fix incorrect plan from bad merge
Tomas Mraz [Mon, 6 Jan 2025 12:03:59 +0000 (13:03 +0100)] 
80-test_cms.t: Fix incorrect plan from bad merge

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26322)

(cherry picked from commit ff10a027f94806c5daed42a1f6488759bed68cd3)

6 months agoFix CMS encryption with key agreement when originator set
Jakub Zelenka [Fri, 13 Dec 2024 12:48:23 +0000 (13:48 +0100)] 
Fix CMS encryption with key agreement when originator set

OpenSSL currently does not support encryption with originator flag so it
should fail nicely instead of segfaulting.

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26014)

(cherry picked from commit 894e69e747a93a1f166891f5f029b78c68088f50)

6 months agoFix originator cert leak in cms app
Jakub Zelenka [Fri, 13 Dec 2024 12:47:25 +0000 (13:47 +0100)] 
Fix originator cert leak in cms app

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26014)

(cherry picked from commit 24dd635efff48a24daf1e38a256550253225a28e)

6 months agoopenssl-pkeyutl.pod.in: update from SHA-1 to SHA256, fixing default values and examples
Dr. David von Oheimb [Fri, 15 Nov 2024 07:49:33 +0000 (08:49 +0100)] 
openssl-pkeyutl.pod.in: update from SHA-1 to SHA256, fixing default values and examples

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25958)

(cherry picked from commit 0a0862969f954dddaae12cf7b598bed6016a55d7)

6 months agoopenssl-pkeyutl.pod.in: various fixes
Dr. David von Oheimb [Thu, 14 Nov 2024 08:43:21 +0000 (09:43 +0100)] 
openssl-pkeyutl.pod.in: various fixes

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25958)

(cherry picked from commit cbb16094c32235e7d85b663e45e21efdce6a9ea2)

6 months agoapps/pkeyutl: Fix checks and documentation regarding -peerkey
Dr. David von Oheimb [Thu, 14 Nov 2024 08:28:16 +0000 (09:28 +0100)] 
apps/pkeyutl: Fix checks and documentation regarding -peerkey

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25958)

(cherry picked from commit ddae593a92b7b451208de42a4b6f25ba30bb41e6)

7 months agoCorrect return value documentation for X509V3_set_ctx()
Michael Baentsch [Wed, 1 Jan 2025 18:27:45 +0000 (19:27 +0100)] 
Correct return value documentation for X509V3_set_ctx()

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26295)

(cherry picked from commit 817a2b2b4955da0233fe7e6e4bd16c0255262b4f)

7 months agoReject invalid FFDHE and ECDHE key shares with SSL_AD_ILLEGAL_PARAMETER alert
cx [Thu, 26 Sep 2024 03:27:14 +0000 (11:27 +0800)] 
Reject invalid FFDHE and ECDHE key shares with SSL_AD_ILLEGAL_PARAMETER alert

This changes the alert according to RFC 8446.

Fixes: #25402
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25547)

(cherry picked from commit 0f6caf740977fa25d0f05cd3c48a656efbd9a79e)

7 months agoFix potential memory leak in BIO_get_accept_socket()
Niels Dossche [Mon, 28 Oct 2024 15:34:55 +0000 (16:34 +0100)] 
Fix potential memory leak in BIO_get_accept_socket()

When BIO_parse_hostserv() fails it may still have allocated memory, yet
this memory is not freed. Fix it by jumping to the err label.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25817)

(cherry picked from commit 32476957ead4151dceaf873306fc7e79cd262812)

7 months agocore_namemap.c: Use OPENSSL_STRING instead of defining STRING type
Tomas Mraz [Fri, 20 Dec 2024 16:20:04 +0000 (17:20 +0100)] 
core_namemap.c: Use OPENSSL_STRING instead of defining STRING type

Also avoid leak if stack push fails.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26230)

(cherry picked from commit 0baa3ac736520c9457c5ef05614fdd54b8dc5515)

7 months agoec_kem.c: Fix ikmlen check
Зишан Мирза [Tue, 24 Dec 2024 06:05:21 +0000 (11:05 +0500)] 
ec_kem.c: Fix ikmlen check

This makes `ikmlen` have a length of at least `Nsk`.

Closes #26213

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26254)

(cherry picked from commit c93f4a1e75efbb10153b2520a10e5a19a4479fdf)

7 months agoAdd a daily run-checker test for the TLS security level
Matt Caswell [Tue, 24 Dec 2024 09:34:27 +0000 (09:34 +0000)] 
Add a daily run-checker test for the TLS security level

Add a test to check that if the user reduces the default TLS security level
at configure time, then the tests still pass.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26256)

(cherry picked from commit 0958f5a5bc47e2cca907a3bfaf14059c020324fd)

7 months agoEnsure the tests pass even if the default seclevel has been changed
Matt Caswell [Tue, 24 Dec 2024 09:29:07 +0000 (09:29 +0000)] 
Ensure the tests pass even if the default seclevel has been changed

The compile time default TLS security level can be changed if the user
sets `-DOPENSSL_TLS_SECURITY_LEVEL=x` at configure time (where "x" is some
number, typically 0 or 1).

Since OpenSSL 3.4 tests are failing if the default security level is 0. We
fix the tests for this case.

Fixes #26255

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26256)

(cherry picked from commit 2986908cc729768f540596df356279a7ba52bc7e)

7 months agoX509_ACERT_sign_ctx(): Remove superfluous reference
ryuishii [Thu, 5 Dec 2024 06:48:51 +0000 (15:48 +0900)] 
X509_ACERT_sign_ctx(): Remove superfluous reference

CLA: trivial

Fixes #26107

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26120)

(cherry picked from commit 5b33d3e158fc93d30c0dc50953a53b02623fe3c5)

7 months agoTake into account no_store when pushing algorithm
Dmitry Belyavskiy [Wed, 18 Dec 2024 20:28:14 +0000 (21:28 +0100)] 
Take into account no_store when pushing algorithm

When we put algorithm to the store, we have a fallback to the
OSSL_LIB_CTX level store when store is NULL.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26197)

(cherry picked from commit b3bb214720f20f3b126ae4b9c330e9a48b835415)

7 months agoThis is a test for nocache provider behavior
Dmitry Belyavskiy [Tue, 17 Dec 2024 15:18:37 +0000 (16:18 +0100)] 
This is a test for nocache provider behavior

A follow-up to #26038

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26197)

(cherry picked from commit f6097c7c5da84a6bd354c57fd6e0ffb2b549f30d)

7 months agoossl_i2c_ASN1_BIT_STRING(): Fix a possible heap buffer overflow
Andrey Tsygunka [Tue, 26 Nov 2024 07:53:31 +0000 (10:53 +0300)] 
ossl_i2c_ASN1_BIT_STRING(): Fix a possible heap buffer overflow

When data contains only zero values a buffer overflow happens.

CLA: trivial

Signed-off-by: Andrey Tsygunka <aitsygunka@yandex.ru>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26190)

(cherry picked from commit bf2dea0e2c6f1cfe1a8222088052ebcc63ab1004)

7 months agosafe_math.h: Check if __GNUC__ is defined
Kalavakolanu, Hema Anmisha [Wed, 18 Dec 2024 05:19:55 +0000 (10:49 +0530)] 
safe_math.h: Check if __GNUC__ is defined

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4880

Facing the below issue after openssl is upgraded

Edk2\CryptoPkg\Library\OpensslLib\openssl\include\internal/safe_math.h(19):
warning C4668: '__GNUC__' is not defined as a preprocessor macro, replacing
with '0' for '#if/#elif'

CLA: trivial

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Kalavakolanu Hema Anmisha <hema.anmisha.kalavakolanu@intel.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26204)

(cherry picked from commit 53b34561b56b60a812f8f65c777d469e18151e8d)

7 months agoCheck whether ctx->pctx != NULL
otherddn1978 [Fri, 13 Dec 2024 15:00:09 +0000 (18:00 +0300)] 
Check whether ctx->pctx != NULL

If it is NULL, ctx->pctx->pmeth dereference will cause a crash.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26176)

(cherry picked from commit 82e7a1130a7d10f4e15c19676a680990b5e3f8fe)

7 months agoUpgrade action/{upload,download}-artifact to v4
Richard Levitte [Mon, 11 Nov 2024 10:45:32 +0000 (11:45 +0100)] 
Upgrade action/{upload,download}-artifact to v4

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/25921)

7 months agoUpdate HISTORY sections of libssl functions > 3.0.0
Michael Baentsch [Thu, 12 Dec 2024 08:01:55 +0000 (09:01 +0100)] 
Update HISTORY sections of libssl functions > 3.0.0

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26158)

(cherry picked from commit 0f77b6f14e064120224a590139ce76ba9e027a79)

7 months agoFix breakage on arm64_32 platforms
Tomas Mraz [Tue, 10 Dec 2024 10:04:31 +0000 (11:04 +0100)] 
Fix breakage on arm64_32 platforms

We just avoid the special handling needed for Apple M1.

Fixes #26135

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/26145)

(cherry picked from commit 79c9cbbe1f9c3b8314312b6d8bb25b7138831e04)

7 months agoopenssl-dgst: Document that xoflen is required for shake
Ryan Farley [Fri, 6 Dec 2024 12:21:45 +0000 (06:21 -0600)] 
openssl-dgst: Document that xoflen is required for shake

With b911fef216d1386210ec24e201d54d709528abb4, there is no longer a
default xoflen for shake algorithms. Update the manual to reflect this.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26129)

(cherry picked from commit ffa1cf69aaf6a2eeabb96cc1326aa4ac24e7f0d9)

7 months agoFix typo in SSL_get_shared_sigalgs docs
Sasha Romijn [Wed, 11 Dec 2024 13:31:12 +0000 (14:31 +0100)] 
Fix typo in SSL_get_shared_sigalgs docs

psighash -> psignhash

CLA: trivial

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26151)

(cherry picked from commit 1b3b5a019a8aab7e92f1a56123880e67fd22e1b5)

7 months agoAdd HISTORY to BIO_s_mem documentation
Michael Baentsch [Tue, 10 Dec 2024 13:35:22 +0000 (14:35 +0100)] 
Add HISTORY to BIO_s_mem documentation

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26146)

(cherry picked from commit 8cbe6e5a8109a831627a683e97e998a7f64401fe)

7 months agoX509: document non-standard behavior checking EKU extensions in CA and TA certs
Dr. David von Oheimb [Mon, 9 Dec 2024 21:22:24 +0000 (22:22 +0100)] 
X509: document non-standard behavior checking EKU extensions in CA and TA certs

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26142)

(cherry picked from commit a82c2bf5c9db9d00f16281b48c1e1430a6cfd76e)

7 months agoFix the intermittent lhash_test failure on Windows
Tomas Mraz [Wed, 11 Dec 2024 14:40:40 +0000 (15:40 +0100)] 
Fix the intermittent lhash_test failure on Windows

We must set pending_delete before the actual deletion as another inserting
or deleting thread can pick up the delete callback before the
ossl_ht_write_unlock() call.

This can happen only if no read locks are pending and only on Windows where
we do not use the write mutex to get the callback list.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26152)

(cherry picked from commit be4ce01f9f51d4ec64b53626834905a8a1de96ca)

7 months agoTo verify MAC, we need a MAC
Dmitry Belyavskiy [Mon, 9 Dec 2024 18:05:33 +0000 (19:05 +0100)] 
To verify MAC, we need a MAC

Fixes #26106

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26140)

(cherry picked from commit 8ad98cce41aa8a6278f7ade6ad2f70b80b194b72)

7 months agodh_cms_set_peerkey(): Fix the incorrect condition
Shakti Shah [Mon, 25 Nov 2024 15:16:45 +0000 (20:46 +0530)] 
dh_cms_set_peerkey(): Fix the incorrect condition

Only absent parameters allowed in RFC 3370.

Fixes #25824

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26058)

(cherry picked from commit 02e72ccffacf2d01295810798ca1c86a438ee712)

7 months agoFix potential use-after-free in REF_PRINT_COUNT
Neil Horman [Wed, 16 Oct 2024 18:34:08 +0000 (14:34 -0400)] 
Fix potential use-after-free in REF_PRINT_COUNT

We use REF_PRINT_COUNT to dump out the value of various reference
counters in our code

However, we commonly use this macro after an increment or decrement.  On
increment its fine, but on decrement its not, because the macro
dereferences the object holding the counter value, which may be freed by
another thread, as we've given up our ref count to it prior to using the
macro.

The rule is that we can't reference memory for an object once we've
released our reference, so lets fix this by altering REF_PRINT_COUNT to
accept the value returned by CRYPTO_[UP|DOWN]_REF instead.  The
eliminates the need to dereference the memory the object points to an
allows us to use the call after we release our reference count

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25664)

(cherry picked from commit dc10ffc2834e0d2f5ebc1c3e29bd97f1f43a0ead)

7 months agoFix memory ordering guarantees and TSAN errors
Tomas Mraz [Thu, 17 Oct 2024 09:25:17 +0000 (11:25 +0200)] 
Fix memory ordering guarantees and TSAN errors

If we had refcounted object allowing lockless writes
the relaxed semantics on DOWN_REF would allow scheduling
these writes after simultaneous release of the object by
another thread.

We do not have any such objects yet, but better to make
the refcount correct just in case we will have them
in future.

TSAN doesn't properly understand this so we use
even stronger acq_rel semantics if building with TSAN.

Fixes #25660

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25664)

(cherry picked from commit 3bf273b21b3e21cca9cd143ed9016397bd7dbb57)

7 months agoAdd test for releasing a shared EVP_PKEY across threads
Tomas Mraz [Thu, 10 Oct 2024 20:10:54 +0000 (22:10 +0200)] 
Add test for releasing a shared EVP_PKEY across threads

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25664)

(cherry picked from commit 420d5d6294449527f4dd986b4fed8681bd4ae8fb)

7 months agoossl_cms_get1_crls_ex(): Avoid doublefree if CRL up ref fails
Tomas Mraz [Thu, 5 Dec 2024 08:29:08 +0000 (09:29 +0100)] 
ossl_cms_get1_crls_ex(): Avoid doublefree if CRL up ref fails

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/26100)

7 months agoRevert the behavior change of CMS_get1_certs() and CMS_get1_crls()
Tomas Mraz [Tue, 3 Dec 2024 11:40:01 +0000 (12:40 +0100)] 
Revert the behavior change of CMS_get1_certs() and CMS_get1_crls()

Fixes #26079

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/26100)

7 months agoRemove references to git.openssl.org from README.md
Tom Cosgrove [Thu, 5 Dec 2024 17:27:52 +0000 (17:27 +0000)] 
Remove references to git.openssl.org from README.md

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26122)

(cherry picked from commit 5f9814d95cc16a6e45e45cc2afe8b98c1eeead25)

8 months agofips-label.yml: Fix ABI change label removal
Tomas Mraz [Thu, 28 Nov 2024 15:58:06 +0000 (16:58 +0100)] 
fips-label.yml: Fix ABI change label removal

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26080)

(cherry picked from commit 85f17585b0d8b55b335f561e2862db14a20b1e64)

8 months agoAvoid NULL dereference with PKCS7_OP_SET_DETACHED_SIGNATURE
Tomas Mraz [Thu, 28 Nov 2024 09:10:28 +0000 (10:10 +0100)] 
Avoid NULL dereference with PKCS7_OP_SET_DETACHED_SIGNATURE

We would dereference p7->d.sign pointer which can be NULL.

Reported by Han Zheng.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26078)

(cherry picked from commit f2348f1f844a54c7a95c32e2354cd29f0860c803)

8 months agoMinor nit fix to EVP_CipherFinal_ex() return code documentation.
Frederik Wedel-Heinen [Fri, 1 Nov 2024 13:18:38 +0000 (14:18 +0100)] 
Minor nit fix to EVP_CipherFinal_ex() return code documentation.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25849)

(cherry picked from commit 54332adf29ef4ddac9dea5ec06423b01dbb02996)

8 months agoFix memleak in dsa_gen()
Holger Dengler [Thu, 14 Nov 2024 08:55:50 +0000 (09:55 +0100)] 
Fix memleak in dsa_gen()

Free the stack return value `dsa` on each early exit.

Fixes #25905

Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25948)

(cherry picked from commit f4550fb5b518d2b910222bca2317d813cf092b53)

8 months agoFix EVP_PKEY_print_private() so that it works with non default providers.
slontis [Wed, 20 Nov 2024 01:39:35 +0000 (12:39 +1100)] 
Fix EVP_PKEY_print_private() so that it works with non default providers.

At some point in time it was decided that the EC keymanagers ec_export()
function would only allow the selection to be both the public + private
parts. If just the private element is selected it returns an error.
Many openssl commandline apps use EVP_PKEY_print_private() which passes
EVP_PKEY_PRIVATE_KEY to the encoder. This selection propagates to
encoder_construct_pkey(). For external providers (such as the fips
provider this will call the keymanagers export() with the selection set
to just the private part.

So we either need to
1) change the selection in EVP_PKEY_print_private() or
2) modify the selection used in the export used in
   encoder_construct_pkey
3) Change the ec_export to allow this.

I have chosen 2) but I am not sure if this is the correct thing to do
or whether it should conditionally do this when the output_type ==
'text'.

Issue was reported by Ilia Okomin (Oracle).

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26004)

(cherry picked from commit 79c98fc6ccab49f02528e06cc046ac61f841a753)

8 months agodie() in .tmpl file should not be silently ignored.
Alexandr Nedvedicky [Tue, 26 Nov 2024 08:05:09 +0000 (09:05 +0100)] 
die() in .tmpl file should not be silently ignored.

call to die() in perl templates is currently ignored.
any error printed by die() commad appears in template
output.

In order to make sure die() terminates processing we
must ensure we emite `undef` value. This is ensured
by adding a `BROKEN` callback to `fill_in()` Template
method. The callback must return undef to stop processing.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26064)

(cherry picked from commit 578760bb6aae6a9d7f3805eea66bab124d06c9b0)

8 months agoFix solaris build in CRYPTO_atomic_store api
Neil Horman [Wed, 27 Nov 2024 17:22:19 +0000 (12:22 -0500)] 
Fix solaris build in CRYPTO_atomic_store api

Misnamed variable, just correct it to dst

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26075)

(cherry picked from commit 4c04a19860d1a6cfaa234463cc0b8e28740d9acb)

8 months agoDocument expected BIO operations for libssl
David Benjamin [Mon, 25 Nov 2024 16:01:17 +0000 (11:01 -0500)] 
Document expected BIO operations for libssl

If your custom BIO does not implement BIO_CTRL_FLUSH, it won't work, but
this is not document anywhere.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26060)

(cherry picked from commit 847a23757f7cbebaa882e15087efb926113a0670)

8 months agoSkip Asymmetric RSA corruption test for >=3.5 FIPS provider
Tomas Mraz [Mon, 25 Nov 2024 09:58:56 +0000 (10:58 +0100)] 
Skip Asymmetric RSA corruption test for >=3.5 FIPS provider

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26049)

8 months agoopenssl-pkeyutl.pod.in: improve description of -rawin and -digest options
Dr. David von Oheimb [Wed, 30 Oct 2024 19:37:38 +0000 (20:37 +0100)] 
openssl-pkeyutl.pod.in: improve description of -rawin and -digest options

Fixes #25827

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/25913)

8 months agoopenssl-pkeyutl.pod.in: add that -sign is default op, update claim on hash needed...
Dr. David von Oheimb [Tue, 29 Oct 2024 18:20:59 +0000 (19:20 +0100)] 
openssl-pkeyutl.pod.in: add that -sign is default op, update claim on hash needed for -sign/-verify, etc.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/25913)