1 // SPDX-License-Identifier: GPL-2.0
3 * fs-verity module initialization and logging
5 * Copyright 2019 Google LLC
8 #include "fsverity_private.h"
10 #include <linux/ratelimit.h>
13 static struct ctl_table_header *fsverity_sysctl_header;
15 static struct ctl_table fsverity_sysctl_table[] = {
16 #ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
18 .procname = "require_signatures",
19 .data = &fsverity_require_signatures,
20 .maxlen = sizeof(int),
22 .proc_handler = proc_dointvec_minmax,
23 .extra1 = SYSCTL_ZERO,
30 static void __init fsverity_init_sysctl(void)
32 fsverity_sysctl_header = register_sysctl("fs/verity",
33 fsverity_sysctl_table);
34 if (!fsverity_sysctl_header)
35 panic("fsverity sysctl registration failed");
37 #else /* CONFIG_SYSCTL */
38 static inline void fsverity_init_sysctl(void)
41 #endif /* !CONFIG_SYSCTL */
43 void fsverity_msg(const struct inode *inode, const char *level,
46 static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
47 DEFAULT_RATELIMIT_BURST);
51 if (!__ratelimit(&rs))
58 printk("%sfs-verity (%s, inode %lu): %pV\n",
59 level, inode->i_sb->s_id, inode->i_ino, &vaf);
61 printk("%sfs-verity: %pV\n", level, &vaf);
65 static int __init fsverity_init(void)
67 fsverity_check_hash_algs();
68 fsverity_init_info_cache();
69 fsverity_init_workqueue();
70 fsverity_init_sysctl();
71 fsverity_init_signature();
74 late_initcall(fsverity_init)