IMA: Define a new hook to measure the kexec boot command line arguments
[linux-2.6-block.git] / include / linux / ima.h
1 /*
2  * Copyright (C) 2008 IBM Corporation
3  * 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.
8  */
9
10 #ifndef _LINUX_IMA_H
11 #define _LINUX_IMA_H
12
13 #include <linux/fs.h>
14 #include <linux/security.h>
15 #include <linux/kexec.h>
16 struct linux_binprm;
17
18 #ifdef CONFIG_IMA
19 extern int ima_bprm_check(struct linux_binprm *bprm);
20 extern int ima_file_check(struct file *file, int mask);
21 extern void ima_post_create_tmpfile(struct inode *inode);
22 extern void ima_file_free(struct file *file);
23 extern int ima_file_mmap(struct file *file, unsigned long prot);
24 extern int ima_load_data(enum kernel_load_data_id id);
25 extern int ima_read_file(struct file *file, enum kernel_read_file_id id);
26 extern int ima_post_read_file(struct file *file, void *buf, loff_t size,
27                               enum kernel_read_file_id id);
28 extern void ima_post_path_mknod(struct dentry *dentry);
29 extern void ima_kexec_cmdline(const void *buf, int size);
30
31 #ifdef CONFIG_IMA_KEXEC
32 extern void ima_add_kexec_buffer(struct kimage *image);
33 #endif
34
35 #if (defined(CONFIG_X86) && defined(CONFIG_EFI)) || defined(CONFIG_S390)
36 extern bool arch_ima_get_secureboot(void);
37 extern const char * const *arch_get_ima_policy(void);
38 #else
39 static inline bool arch_ima_get_secureboot(void)
40 {
41         return false;
42 }
43
44 static inline const char * const *arch_get_ima_policy(void)
45 {
46         return NULL;
47 }
48 #endif
49
50 #else
51 static inline int ima_bprm_check(struct linux_binprm *bprm)
52 {
53         return 0;
54 }
55
56 static inline int ima_file_check(struct file *file, int mask)
57 {
58         return 0;
59 }
60
61 static inline void ima_post_create_tmpfile(struct inode *inode)
62 {
63 }
64
65 static inline void ima_file_free(struct file *file)
66 {
67         return;
68 }
69
70 static inline int ima_file_mmap(struct file *file, unsigned long prot)
71 {
72         return 0;
73 }
74
75 static inline int ima_load_data(enum kernel_load_data_id id)
76 {
77         return 0;
78 }
79
80 static inline int ima_read_file(struct file *file, enum kernel_read_file_id id)
81 {
82         return 0;
83 }
84
85 static inline int ima_post_read_file(struct file *file, void *buf, loff_t size,
86                                      enum kernel_read_file_id id)
87 {
88         return 0;
89 }
90
91 static inline void ima_post_path_mknod(struct dentry *dentry)
92 {
93         return;
94 }
95
96 static inline void ima_kexec_cmdline(const void *buf, int size) {}
97 #endif /* CONFIG_IMA */
98
99 #ifndef CONFIG_IMA_KEXEC
100 struct kimage;
101
102 static inline void ima_add_kexec_buffer(struct kimage *image)
103 {}
104 #endif
105
106 #ifdef CONFIG_IMA_APPRAISE
107 extern bool is_ima_appraise_enabled(void);
108 extern void ima_inode_post_setattr(struct dentry *dentry);
109 extern int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
110                        const void *xattr_value, size_t xattr_value_len);
111 extern int ima_inode_removexattr(struct dentry *dentry, const char *xattr_name);
112 #else
113 static inline bool is_ima_appraise_enabled(void)
114 {
115         return 0;
116 }
117
118 static inline void ima_inode_post_setattr(struct dentry *dentry)
119 {
120         return;
121 }
122
123 static inline int ima_inode_setxattr(struct dentry *dentry,
124                                      const char *xattr_name,
125                                      const void *xattr_value,
126                                      size_t xattr_value_len)
127 {
128         return 0;
129 }
130
131 static inline int ima_inode_removexattr(struct dentry *dentry,
132                                         const char *xattr_name)
133 {
134         return 0;
135 }
136 #endif /* CONFIG_IMA_APPRAISE */
137 #endif /* _LINUX_IMA_H */