Skip to contentSkip to conversation

crypto: jitter - panic on runtime health test failures in FIPS mode

PATCH New Vladis Dronov 1 participant 1 message Mar 8, 2023 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: jitter - panic on runtime health test failures in FIPS mode

A FIPS certification lab has noted that the kernel doesn't go to error state upon failure of the RCT and APT health tests. Add a panic() call in FIPS mode to jent_kcapi_random().

Revert b454fb702515 ("crypto: jitter - don't limit ->health_failure check to FIPS mode") for this partially.

---
 crypto/jitterentropy-kcapi.c | 8 ++++++++
 crypto/jitterentropy.h       | 1 +
 2 files changed, 9 insertions(+)
crypto/jitterentropy-kcapi.c +8 -0
index 2d115bec15ae..9c692119d926 100644
@@ -37,6 +37,7 @@
  * DAMAGE.
  */
 
+#include <linux/fips.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -59,6 +60,11 @@ void jent_zfree(void *ptr)
 	kfree_sensitive(ptr);
 }
 
+int jent_fips_enabled(void)
+{
+	return fips_enabled;
+}
+
 void jent_panic(char *s)
 {
 	panic("%s", s);
@@ -140,6 +146,8 @@ static int jent_kcapi_random(struct crypto_rng *tfm,
 
 	/* Return a permanent error in case we had too many resets in a row. */
 	if (rng->reset_cnt > (1<<10)) {
+		if (jent_fips_enabled())
+			jent_panic("jitterentropy: Too many RCT/APT health test failures\n");
 		ret = -EFAULT;
 		goto out;
 	}
crypto/jitterentropy.h +1 -0
index b7397b617ef0..c83fff32d130 100644
@@ -2,6 +2,7 @@
 
 extern void *jent_zalloc(unsigned int len);
 extern void jent_zfree(void *ptr);
+extern int jent_fips_enabled(void);
 extern void jent_panic(char *s);
 extern void jent_memcpy(void *dest, const void *src, unsigned int n);
 extern void jent_get_nstime(__u64 *out);
Signature · 1 line
2.39.2