hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/ima.h
....@@ -1,15 +1,13 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2008 IBM Corporation
34 * Author: Mimi Zohar <zohar@us.ibm.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, version 2 of the License.
85 */
96
107 #ifndef _LINUX_IMA_H
118 #define _LINUX_IMA_H
129
10
+#include <linux/kernel_read_file.h>
1311 #include <linux/fs.h>
1412 #include <linux/security.h>
1513 #include <linux/kexec.h>
....@@ -18,16 +16,38 @@
1816 #ifdef CONFIG_IMA
1917 extern int ima_bprm_check(struct linux_binprm *bprm);
2018 extern int ima_file_check(struct file *file, int mask);
19
+extern void ima_post_create_tmpfile(struct inode *inode);
2120 extern void ima_file_free(struct file *file);
2221 extern int ima_file_mmap(struct file *file, unsigned long prot);
23
-extern int ima_load_data(enum kernel_load_data_id id);
24
-extern int ima_read_file(struct file *file, enum kernel_read_file_id id);
22
+extern int ima_file_mprotect(struct vm_area_struct *vma, unsigned long prot);
23
+extern int ima_load_data(enum kernel_load_data_id id, bool contents);
24
+extern int ima_post_load_data(char *buf, loff_t size,
25
+ enum kernel_load_data_id id, char *description);
26
+extern int ima_read_file(struct file *file, enum kernel_read_file_id id,
27
+ bool contents);
2528 extern int ima_post_read_file(struct file *file, void *buf, loff_t size,
2629 enum kernel_read_file_id id);
2730 extern void ima_post_path_mknod(struct dentry *dentry);
31
+extern int ima_file_hash(struct file *file, char *buf, size_t buf_size);
32
+extern void ima_kexec_cmdline(int kernel_fd, const void *buf, int size);
2833
2934 #ifdef CONFIG_IMA_KEXEC
3035 extern void ima_add_kexec_buffer(struct kimage *image);
36
+#endif
37
+
38
+#ifdef CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT
39
+extern bool arch_ima_get_secureboot(void);
40
+extern const char * const *arch_get_ima_policy(void);
41
+#else
42
+static inline bool arch_ima_get_secureboot(void)
43
+{
44
+ return false;
45
+}
46
+
47
+static inline const char * const *arch_get_ima_policy(void)
48
+{
49
+ return NULL;
50
+}
3151 #endif
3252
3353 #else
....@@ -41,6 +61,10 @@
4161 return 0;
4262 }
4363
64
+static inline void ima_post_create_tmpfile(struct inode *inode)
65
+{
66
+}
67
+
4468 static inline void ima_file_free(struct file *file)
4569 {
4670 return;
....@@ -51,12 +75,26 @@
5175 return 0;
5276 }
5377
54
-static inline int ima_load_data(enum kernel_load_data_id id)
78
+static inline int ima_file_mprotect(struct vm_area_struct *vma,
79
+ unsigned long prot)
5580 {
5681 return 0;
5782 }
5883
59
-static inline int ima_read_file(struct file *file, enum kernel_read_file_id id)
84
+static inline int ima_load_data(enum kernel_load_data_id id, bool contents)
85
+{
86
+ return 0;
87
+}
88
+
89
+static inline int ima_post_load_data(char *buf, loff_t size,
90
+ enum kernel_load_data_id id,
91
+ char *description)
92
+{
93
+ return 0;
94
+}
95
+
96
+static inline int ima_read_file(struct file *file, enum kernel_read_file_id id,
97
+ bool contents)
6098 {
6199 return 0;
62100 }
....@@ -72,6 +110,12 @@
72110 return;
73111 }
74112
113
+static inline int ima_file_hash(struct file *file, char *buf, size_t buf_size)
114
+{
115
+ return -EOPNOTSUPP;
116
+}
117
+
118
+static inline void ima_kexec_cmdline(int kernel_fd, const void *buf, int size) {}
75119 #endif /* CONFIG_IMA */
76120
77121 #ifndef CONFIG_IMA_KEXEC
....@@ -80,6 +124,20 @@
80124 static inline void ima_add_kexec_buffer(struct kimage *image)
81125 {}
82126 #endif
127
+
128
+#ifdef CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS
129
+extern void ima_post_key_create_or_update(struct key *keyring,
130
+ struct key *key,
131
+ const void *payload, size_t plen,
132
+ unsigned long flags, bool create);
133
+#else
134
+static inline void ima_post_key_create_or_update(struct key *keyring,
135
+ struct key *key,
136
+ const void *payload,
137
+ size_t plen,
138
+ unsigned long flags,
139
+ bool create) {}
140
+#endif /* CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS */
83141
84142 #ifdef CONFIG_IMA_APPRAISE
85143 extern bool is_ima_appraise_enabled(void);
....@@ -112,4 +170,13 @@
112170 return 0;
113171 }
114172 #endif /* CONFIG_IMA_APPRAISE */
173
+
174
+#if defined(CONFIG_IMA_APPRAISE) && defined(CONFIG_INTEGRITY_TRUSTED_KEYRING)
175
+extern bool ima_appraise_signature(enum kernel_read_file_id func);
176
+#else
177
+static inline bool ima_appraise_signature(enum kernel_read_file_id func)
178
+{
179
+ return false;
180
+}
181
+#endif /* CONFIG_IMA_APPRAISE && CONFIG_INTEGRITY_TRUSTED_KEYRING */
115182 #endif /* _LINUX_IMA_H */