From: Vladis Dronov <vdronov@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
"David S . Miller" <davem@davemloft.net>,
Stephan Mueller <smueller@chronox.de>
Cc: Nicolai Stange <nstange@suse.de>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
Vladis Dronov <vdronov@redhat.com>
Subject: [PATCH] crypto: jitter - panic on runtime health test failures in FIPS mode
Date: Wed, 8 Mar 2023 18:02:33 +0100 [thread overview]
Message-ID: <20230308170233.19475-1-vdronov@redhat.com> (raw)
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.
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
---
crypto/jitterentropy-kcapi.c | 8 ++++++++
crypto/jitterentropy.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
index 2d115bec15ae..9c692119d926 100644
--- a/crypto/jitterentropy-kcapi.c
+++ b/crypto/jitterentropy-kcapi.c
@@ -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;
}
diff --git a/crypto/jitterentropy.h b/crypto/jitterentropy.h
index b7397b617ef0..c83fff32d130 100644
--- a/crypto/jitterentropy.h
+++ b/crypto/jitterentropy.h
@@ -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);
--
2.39.2
reply other threads:[~2023-03-08 17:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230308170233.19475-1-vdronov@redhat.com \
--to=vdronov@redhat.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nstange@suse.de \
--cc=smueller@chronox.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®