2
* Copyright 2023 Red Hat, Inc. and/or its affiliates
3
* and other contributors as indicated by the @author tags.
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
19
* https://github.com/torvalds/linux/blob/master/crypto/fips.c
20
* https://pointer-overloading.blogspot.com/2013/09/linux-creating-entry-in-proc-file.html
23
#include <linux/module.h>
24
#include <linux/sysctl.h>
25
#include <linux/version.h>
29
static struct ctl_table crypto_sysctl_table[] = {
31
.procname = "fips_enabled",
32
.data = &fips_enabled,
33
.maxlen = sizeof(int),
35
.proc_handler = proc_dointvec
39
static struct ctl_table crypto_dir_table[] = {
43
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0))
44
.child = crypto_sysctl_table
50
static struct ctl_table_header *crypto_sysctls;
52
static void crypto_proc_fips_init(void)
54
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0))
55
crypto_sysctls = register_sysctl_table(crypto_dir_table);
57
crypto_sysctls = register_sysctl(crypto_dir_table->procname, crypto_sysctl_table);
61
static void crypto_proc_fips_exit(void)
63
unregister_sysctl_table(crypto_sysctls);
66
static int __init fips_init(void)
68
crypto_proc_fips_init();
72
static void __exit fips_exit(void)
74
crypto_proc_fips_exit();
78
subsys_initcall(fips_init);
79
module_exit(fips_exit);