|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
From aa3aebf132959e7e44876042efaf9ff24ffe0f2b Mon Sep 17 00:00:00 2001
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
From: rpm-build <rpm-build>
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
Date: Mon, 31 Jul 2023 09:41:27 +0200
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
Subject: [PATCH 09/35] 0009-Add-Kernel-FIPS-mode-flag-support.patch
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
Patch-name: 0009-Add-Kernel-FIPS-mode-flag-support.patch
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
Patch-id: 9
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
Patch-status: |
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
# Add check to see if fips flag is enabled in kernel
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
From-dist-git-commit: 9409bc7044cf4b5773639cce20f51399888c45fd
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
---
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
crypto/context.c | 36 ++++++++++++++++++++++++++++++++++++
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
include/internal/provider.h | 3 +++
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
2 files changed, 39 insertions(+)
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
diff --git a/crypto/context.c b/crypto/context.c
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
index e294ea1512..51002ba79a 100644
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
--- a/crypto/context.c
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
+++ b/crypto/context.c
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
@@ -16,6 +16,41 @@
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
9409bc7 |
#include "internal/provider.h"
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
9409bc7 |
#include "crypto/context.h"
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+# include <sys/types.h>
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+# include <sys/stat.h>
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+# include <fcntl.h>
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+# include <unistd.h>
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+# include <openssl/evp.h>
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+# define FIPS_MODE_SWITCH_FILE "/proc/sys/crypto/fips_enabled"
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+static int kernel_fips_flag;
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+static void read_kernel_fips_flag(void)
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+{
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ char buf[2] = "0";
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ int fd;
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ if (ossl_safe_getenv("OPENSSL_FORCE_FIPS_MODE") != NULL) {
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ buf[0] = '1';
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ } else if ((fd = open(FIPS_MODE_SWITCH_FILE, O_RDONLY)) >= 0) {
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ while (read(fd, buf, sizeof(buf)) < 0 && errno == EINTR) ;
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ close(fd);
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ if (buf[0] == '1') {
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ kernel_fips_flag = 1;
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ return;
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+}
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
+int ossl_get_kernel_fips_flag()
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+{
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
+ return kernel_fips_flag;
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+}
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
struct ossl_lib_ctx_st {
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
9409bc7 |
CRYPTO_RWLOCK *lock, *rand_crngt_lock;
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
9409bc7 |
OSSL_EX_DATA_GLOBAL global;
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
@@ -336,6 +371,7 @@ static int default_context_inited = 0;
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
DEFINE_RUN_ONCE_STATIC(default_context_do_init)
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
{
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
347681c |
+ read_kernel_fips_flag();
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
9409bc7 |
if (!CRYPTO_THREAD_init_local(&default_context_thread_local, NULL))
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
9409bc7 |
goto err;
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
9409bc7 |
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
diff --git a/include/internal/provider.h b/include/internal/provider.h
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
index 18937f84c7..1446bf7afb 100644
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
--- a/include/internal/provider.h
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
+++ b/include/internal/provider.h
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
@@ -112,6 +112,9 @@ int ossl_provider_init_as_child(OSSL_LIB_CTX *ctx,
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
const OSSL_DISPATCH *in);
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
void ossl_provider_deinit_child(OSSL_LIB_CTX *ctx);
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
+/* FIPS flag access */
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
+int ossl_get_kernel_fips_flag(void);
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
+
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
# ifdef __cplusplus
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
}
|
|
![](https://seccdn.libravatar.org/avatar/bf58c36eec674fb2fe8744438582f820d6a15548097263146b8ffabcab17025a?s=16&d=retro) |
080143c |
# endif
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
--
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
2.41.0
|
|
![](https://seccdn.libravatar.org/avatar/51e79f1c8f0708302b10d192df7f68f65a35a40baf326e94c95366eb1dfd12fc?s=16&d=retro) |
1eb7adc |
|