forked from pool/openssl-1_1
Pedro Monreal Gonzalez
8f01c56ec8
- Update to 1.1.1w: * Fix POLY1305 MAC implementation corrupting XMM registers on Windows. The POLY1305 MAC (message authentication code) implementation in OpenSSL does not save the contents of non-volatile XMM registers on Windows 64 platform when calculating the MAC of data larger than 64 bytes. Before returning to the caller all the XMM registers are set to zero rather than restoring their previous content. The vulnerable code is used only on newer x86_64 processors supporting the AVX512-IFMA instructions. The consequences of this kind of internal application state corruption can be various - from no consequences, if the calling application does not depend on the contents of non-volatile XMM registers at all, to the worst consequences, where the attacker could get complete control of the application process. However given the contents of the registers are just zeroized so the attacker cannot put arbitrary values inside, the most likely consequence, if any, would be an incorrect result of some application dependent calculations or a crash leading to a denial of service. (CVE-2023-4807) - Add missing FIPS patches from SLE: * Add patches: - bsc1185319-FIPS-KAT-for-ECDSA.patch - bsc1198207-FIPS-add-hash_hmac-drbg-kat.patch - openssl-1.1.1-fips-fix-memory-leaks.patch - openssl-1_1-FIPS-PBKDF2-KAT-requirements.patch - openssl-1_1-FIPS_drbg-rewire.patch - openssl-1_1-Zeroization.patch - openssl-1_1-fips-drbg-selftest.patch - openssl-1_1-fips-list-only-approved-digest-and-pubkey-algorithms.patch - openssl-1_1-jitterentropy-3.4.0.patch - openssl-1_1-ossl-sli-000-fix-build-error.patch OBS-URL: https://build.opensuse.org/request/show/1111331 OBS-URL: https://build.opensuse.org/package/show/security:tls/openssl-1_1?expand=0&rev=144
81 lines
2.4 KiB
Diff
81 lines
2.4 KiB
Diff
---
|
|
crypto/fips/fips_entropy.c | 40 ++++++++++++++++++++++++++++++++++++++--
|
|
1 file changed, 38 insertions(+), 2 deletions(-)
|
|
|
|
--- a/crypto/fips/fips_entropy.c
|
|
+++ b/crypto/fips/fips_entropy.c
|
|
@@ -4,35 +4,71 @@
|
|
#include "jitterentropy.h"
|
|
|
|
static struct rand_data* ec = NULL;
|
|
+static CRYPTO_RWLOCK *jent_lock = NULL;
|
|
+static int stop = 0;
|
|
|
|
struct rand_data* FIPS_entropy_init(void)
|
|
{
|
|
- if (ec != NULL)
|
|
+ if (ec != NULL) {
|
|
/* Entropy source has been initiated and collector allocated */
|
|
return ec;
|
|
+ }
|
|
+ if (stop != 0) {
|
|
+ /* FIPS_entropy_cleanup() already called, don't initialize it again */
|
|
+ return NULL;
|
|
+ }
|
|
+ if (jent_lock == NULL) {
|
|
+ /* Allocates a new lock to serialize access to jent library */
|
|
+ jent_lock = CRYPTO_THREAD_lock_new();
|
|
+ if (jent_lock == NULL) {
|
|
+ return NULL;
|
|
+ }
|
|
+ }
|
|
+ if (CRYPTO_THREAD_write_lock(jent_lock) == 0) {
|
|
+ return NULL;
|
|
+ }
|
|
/* If the initialization is successful, the call returns with 0 */
|
|
if (jent_entropy_init_ex(1, JENT_FORCE_FIPS) == 0)
|
|
/* Allocate entropy collector */
|
|
ec = jent_entropy_collector_alloc(1, JENT_FORCE_FIPS);
|
|
+ CRYPTO_THREAD_unlock(jent_lock);
|
|
return ec;
|
|
}
|
|
|
|
void FIPS_entropy_cleanup(void)
|
|
{
|
|
+ if (jent_lock != NULL && stop == 0) {
|
|
+ CRYPTO_THREAD_write_lock(jent_lock);
|
|
+ }
|
|
+ /* Disable re-initialization in FIPS_entropy_init() */
|
|
+ stop = 1;
|
|
/* Free entropy collector */
|
|
if (ec != NULL) {
|
|
jent_entropy_collector_free(ec);
|
|
ec = NULL;
|
|
}
|
|
+ CRYPTO_THREAD_lock_free(jent_lock);
|
|
+ jent_lock = NULL;
|
|
}
|
|
|
|
ssize_t FIPS_jitter_entropy(unsigned char *buf, size_t buflen)
|
|
{
|
|
ssize_t ent_bytes = -1;
|
|
|
|
- if (buf != NULL && buflen != 0 && FIPS_entropy_init()) {
|
|
+ /*
|
|
+ * Order is important. We need to call FIPS_entropy_init() before we
|
|
+ * acquire jent_lock, otherwise it can lead to deadlock. Once we have
|
|
+ * jent_lock, we need to ensure that FIPS_entropy_cleanup() was not called
|
|
+ * in the meantime. Then it's safe to read entropy.
|
|
+ */
|
|
+ if (buf != NULL
|
|
+ && buflen != 0
|
|
+ && FIPS_entropy_init()
|
|
+ && CRYPTO_THREAD_write_lock(jent_lock) != 0
|
|
+ && stop == 0) {
|
|
/* Get entropy */
|
|
ent_bytes = jent_read_entropy_safe(&ec, (char *)buf, buflen);
|
|
+ CRYPTO_THREAD_unlock(jent_lock);
|
|
}
|
|
return ent_bytes;
|
|
}
|