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_file_free(struct file *file);
22 extern int ima_file_mmap(struct file *file, unsigned long reqprot,
23 unsigned long prot, unsigned long flags);
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
30 #ifdef CONFIG_IMA_KEXEC
31 extern void ima_add_kexec_buffer(struct kimage *image);
32 #endif
33
34 #else
ima_bprm_check(struct linux_binprm * bprm)35 static inline int ima_bprm_check(struct linux_binprm *bprm)
36 {
37 return 0;
38 }
39
ima_file_check(struct file * file,int mask)40 static inline int ima_file_check(struct file *file, int mask)
41 {
42 return 0;
43 }
44
ima_file_free(struct file * file)45 static inline void ima_file_free(struct file *file)
46 {
47 return;
48 }
49
ima_file_mmap(struct file * file,unsigned long reqprot,unsigned long prot,unsigned long flags)50 static inline int ima_file_mmap(struct file *file, unsigned long reqprot,
51 unsigned long prot, unsigned long flags)
52 {
53 return 0;
54 }
55
ima_load_data(enum kernel_load_data_id id)56 static inline int ima_load_data(enum kernel_load_data_id id)
57 {
58 return 0;
59 }
60
ima_read_file(struct file * file,enum kernel_read_file_id id)61 static inline int ima_read_file(struct file *file, enum kernel_read_file_id id)
62 {
63 return 0;
64 }
65
ima_post_read_file(struct file * file,void * buf,loff_t size,enum kernel_read_file_id id)66 static inline int ima_post_read_file(struct file *file, void *buf, loff_t size,
67 enum kernel_read_file_id id)
68 {
69 return 0;
70 }
71
ima_post_path_mknod(struct dentry * dentry)72 static inline void ima_post_path_mknod(struct dentry *dentry)
73 {
74 return;
75 }
76
77 #endif /* CONFIG_IMA */
78
79 #ifndef CONFIG_IMA_KEXEC
80 struct kimage;
81
ima_add_kexec_buffer(struct kimage * image)82 static inline void ima_add_kexec_buffer(struct kimage *image)
83 {}
84 #endif
85
86 #ifdef CONFIG_IMA_APPRAISE
87 extern bool is_ima_appraise_enabled(void);
88 extern void ima_inode_post_setattr(struct dentry *dentry);
89 extern int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
90 const void *xattr_value, size_t xattr_value_len);
91 extern int ima_inode_removexattr(struct dentry *dentry, const char *xattr_name);
92 #else
is_ima_appraise_enabled(void)93 static inline bool is_ima_appraise_enabled(void)
94 {
95 return 0;
96 }
97
ima_inode_post_setattr(struct dentry * dentry)98 static inline void ima_inode_post_setattr(struct dentry *dentry)
99 {
100 return;
101 }
102
ima_inode_setxattr(struct dentry * dentry,const char * xattr_name,const void * xattr_value,size_t xattr_value_len)103 static inline int ima_inode_setxattr(struct dentry *dentry,
104 const char *xattr_name,
105 const void *xattr_value,
106 size_t xattr_value_len)
107 {
108 return 0;
109 }
110
ima_inode_removexattr(struct dentry * dentry,const char * xattr_name)111 static inline int ima_inode_removexattr(struct dentry *dentry,
112 const char *xattr_name)
113 {
114 return 0;
115 }
116 #endif /* CONFIG_IMA_APPRAISE */
117 #endif /* _LINUX_IMA_H */
118