Blame SOURCES/cryptsetup-2.4.1-Cache-FIPS-mode-check.patch
|
|
79c0bd |
From 75e45462f097a9a75747b3f44d7672f2547e63e9 Mon Sep 17 00:00:00 2001
|
|
|
79c0bd |
From: Milan Broz <gmazyland@gmail.com>
|
|
|
79c0bd |
Date: Tue, 14 Sep 2021 09:56:05 +0200
|
|
|
79c0bd |
Subject: [PATCH 04/11] Cache FIPS mode check.
|
|
|
79c0bd |
|
|
|
79c0bd |
We do not support switch while the crypto backend is already initialized,
|
|
|
79c0bd |
so it does not make sense to check repeatedly for the FIPS mode status.
|
|
|
79c0bd |
---
|
|
|
79c0bd |
lib/utils_fips.c | 11 ++++++++++-
|
|
|
79c0bd |
1 file changed, 10 insertions(+), 1 deletion(-)
|
|
|
79c0bd |
|
|
|
79c0bd |
diff --git a/lib/utils_fips.c b/lib/utils_fips.c
|
|
|
79c0bd |
index 0c2b6434..640ff0e3 100644
|
|
|
79c0bd |
--- a/lib/utils_fips.c
|
|
|
79c0bd |
+++ b/lib/utils_fips.c
|
|
|
79c0bd |
@@ -26,6 +26,9 @@
|
|
|
79c0bd |
#if !ENABLE_FIPS
|
|
|
79c0bd |
bool crypt_fips_mode(void) { return false; }
|
|
|
79c0bd |
#else
|
|
|
79c0bd |
+static bool fips_checked = false;
|
|
|
79c0bd |
+static bool fips_mode = false;
|
|
|
79c0bd |
+
|
|
|
79c0bd |
static bool kernel_fips_mode(void)
|
|
|
79c0bd |
{
|
|
|
79c0bd |
int fd;
|
|
|
79c0bd |
@@ -41,6 +44,12 @@ static bool kernel_fips_mode(void)
|
|
|
79c0bd |
|
|
|
79c0bd |
bool crypt_fips_mode(void)
|
|
|
79c0bd |
{
|
|
|
79c0bd |
- return kernel_fips_mode() && !access("/etc/system-fips", F_OK);
|
|
|
79c0bd |
+ if (fips_checked)
|
|
|
79c0bd |
+ return fips_mode;
|
|
|
79c0bd |
+
|
|
|
79c0bd |
+ fips_mode = kernel_fips_mode() && !access("/etc/system-fips", F_OK);
|
|
|
79c0bd |
+ fips_checked = true;
|
|
|
79c0bd |
+
|
|
|
79c0bd |
+ return fips_mode;
|
|
|
79c0bd |
}
|
|
|
79c0bd |
#endif /* ENABLE_FIPS */
|
|
|
79c0bd |
--
|
|
|
79c0bd |
2.27.0
|
|
|
79c0bd |
|