summaryrefslogtreecommitdiff
path: root/crypto/fips.c
diff options
context:
space:
mode:
authorGilad Ben-Yossef <gilad@benyossef.com>2019-07-02 14:39:20 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2019-07-26 14:51:57 +1000
commit69017f14631c4376c8a372a026d77b4f11876fbc (patch)
tree20f6cc64ad624098a8363687e0fc2cd6183ca42b /crypto/fips.c
parent0a4fa7ef65b9f8d2d8cd0db31769f3a0eb77e76f (diff)
downloadlinux-crypto-69017f14631c4376c8a372a026d77b4f11876fbc.tar.gz
linux-crypto-69017f14631c4376c8a372a026d77b4f11876fbc.zip
crypto: fips - add FIPS test failure notification chain
Crypto test failures in FIPS mode cause an immediate panic, but on some system the cryptographic boundary extends beyond just the Linux controlled domain. Add a simple atomic notification chain to allow interested parties to register to receive notification prior to us kicking the bucket. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/fips.c')
-rw-r--r--crypto/fips.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/crypto/fips.c b/crypto/fips.c
index c0b3a3c3..7b1d8cae 100644
--- a/crypto/fips.c
+++ b/crypto/fips.c
@@ -11,10 +11,14 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sysctl.h>
+#include <linux/notifier.h>
int fips_enabled;
EXPORT_SYMBOL_GPL(fips_enabled);
+ATOMIC_NOTIFIER_HEAD(fips_fail_notif_chain);
+EXPORT_SYMBOL_GPL(fips_fail_notif_chain);
+
/* Process kernel command-line parameter at boot time. fips=0 or fips=1 */
static int fips_enable(char *str)
{
@@ -58,6 +62,13 @@ static void crypto_proc_fips_exit(void)
unregister_sysctl_table(crypto_sysctls);
}
+void fips_fail_notify(void)
+{
+ if (fips_enabled)
+ atomic_notifier_call_chain(&fips_fail_notif_chain, 0, NULL);
+}
+EXPORT_SYMBOL_GPL(fips_fail_notify);
+
static int __init fips_init(void)
{
crypto_proc_fips_init();