| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * FIPS 200 support. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2008 Neil Horman <nhorman@tuxdriver.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - * under the terms of the GNU General Public License as published by the Free |
|---|
| 8 | | - * Software Foundation; either version 2 of the License, or (at your option) |
|---|
| 9 | | - * any later version. |
|---|
| 10 | | - * |
|---|
| 11 | 6 | */ |
|---|
| 12 | 7 | |
|---|
| 13 | 8 | #include <linux/export.h> |
|---|
| .. | .. |
|---|
| 16 | 11 | #include <linux/module.h> |
|---|
| 17 | 12 | #include <linux/kernel.h> |
|---|
| 18 | 13 | #include <linux/sysctl.h> |
|---|
| 14 | +#include <linux/notifier.h> |
|---|
| 19 | 15 | |
|---|
| 20 | 16 | int fips_enabled; |
|---|
| 21 | 17 | EXPORT_SYMBOL_GPL(fips_enabled); |
|---|
| 18 | + |
|---|
| 19 | +ATOMIC_NOTIFIER_HEAD(fips_fail_notif_chain); |
|---|
| 20 | +EXPORT_SYMBOL_GPL(fips_fail_notif_chain); |
|---|
| 22 | 21 | |
|---|
| 23 | 22 | /* Process kernel command-line parameter at boot time. fips=0 or fips=1 */ |
|---|
| 24 | 23 | static int fips_enable(char *str) |
|---|
| .. | .. |
|---|
| 63 | 62 | unregister_sysctl_table(crypto_sysctls); |
|---|
| 64 | 63 | } |
|---|
| 65 | 64 | |
|---|
| 65 | +void fips_fail_notify(void) |
|---|
| 66 | +{ |
|---|
| 67 | + if (fips_enabled) |
|---|
| 68 | + atomic_notifier_call_chain(&fips_fail_notif_chain, 0, NULL); |
|---|
| 69 | +} |
|---|
| 70 | +EXPORT_SYMBOL_GPL(fips_fail_notify); |
|---|
| 71 | + |
|---|
| 66 | 72 | static int __init fips_init(void) |
|---|
| 67 | 73 | { |
|---|
| 68 | 74 | crypto_proc_fips_init(); |
|---|
| .. | .. |
|---|
| 74 | 80 | crypto_proc_fips_exit(); |
|---|
| 75 | 81 | } |
|---|
| 76 | 82 | |
|---|
| 77 | | -module_init(fips_init); |
|---|
| 83 | +subsys_initcall(fips_init); |
|---|
| 78 | 84 | module_exit(fips_exit); |
|---|