nvme-rdma: cancel async events before freeing event struct
[linux/fpc-iii.git] / crypto / fips.c
blob7b1d8caee669292b5f039c5ab1047fddcf09966e
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * FIPS 200 support.
5 * Copyright (c) 2008 Neil Horman <nhorman@tuxdriver.com>
6 */
8 #include <linux/export.h>
9 #include <linux/fips.h>
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/sysctl.h>
14 #include <linux/notifier.h>
16 int fips_enabled;
17 EXPORT_SYMBOL_GPL(fips_enabled);
19 ATOMIC_NOTIFIER_HEAD(fips_fail_notif_chain);
20 EXPORT_SYMBOL_GPL(fips_fail_notif_chain);
22 /* Process kernel command-line parameter at boot time. fips=0 or fips=1 */
23 static int fips_enable(char *str)
25 fips_enabled = !!simple_strtol(str, NULL, 0);
26 printk(KERN_INFO "fips mode: %s\n",
27 fips_enabled ? "enabled" : "disabled");
28 return 1;
31 __setup("fips=", fips_enable);
33 static struct ctl_table crypto_sysctl_table[] = {
35 .procname = "fips_enabled",
36 .data = &fips_enabled,
37 .maxlen = sizeof(int),
38 .mode = 0444,
39 .proc_handler = proc_dointvec
44 static struct ctl_table crypto_dir_table[] = {
46 .procname = "crypto",
47 .mode = 0555,
48 .child = crypto_sysctl_table
53 static struct ctl_table_header *crypto_sysctls;
55 static void crypto_proc_fips_init(void)
57 crypto_sysctls = register_sysctl_table(crypto_dir_table);
60 static void crypto_proc_fips_exit(void)
62 unregister_sysctl_table(crypto_sysctls);
65 void fips_fail_notify(void)
67 if (fips_enabled)
68 atomic_notifier_call_chain(&fips_fail_notif_chain, 0, NULL);
70 EXPORT_SYMBOL_GPL(fips_fail_notify);
72 static int __init fips_init(void)
74 crypto_proc_fips_init();
75 return 0;
78 static void __exit fips_exit(void)
80 crypto_proc_fips_exit();
83 subsys_initcall(fips_init);
84 module_exit(fips_exit);