Mimi Zohar | 6146f0d | 2009-02-04 09:06:57 -0500 | [diff] [blame] | 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 | |
Mimi Zohar | 6146f0d | 2009-02-04 09:06:57 -0500 | [diff] [blame] | 10 | #ifndef _LINUX_IMA_H |
| 11 | #define _LINUX_IMA_H |
| 12 | |
Mimi Zohar | ed850a5 | 2009-02-10 23:01:19 -0500 | [diff] [blame] | 13 | #include <linux/fs.h> |
Mimi Zohar | 16c267a | 2018-07-13 14:05:58 -0400 | [diff] [blame] | 14 | #include <linux/security.h> |
Mimi Zohar | 7b8589c | 2016-12-19 16:22:48 -0800 | [diff] [blame] | 15 | #include <linux/kexec.h> |
Mimi Zohar | ed850a5 | 2009-02-10 23:01:19 -0500 | [diff] [blame] | 16 | struct linux_binprm; |
| 17 | |
Mimi Zohar | 3323eec | 2009-02-04 09:06:58 -0500 | [diff] [blame] | 18 | #ifdef CONFIG_IMA |
| 19 | extern int ima_bprm_check(struct linux_binprm *bprm); |
Al Viro | 6035a27 | 2018-06-08 13:40:10 -0400 | [diff] [blame] | 20 | extern int ima_file_check(struct file *file, int mask); |
Mimi Zohar | 3323eec | 2009-02-04 09:06:58 -0500 | [diff] [blame] | 21 | extern void ima_file_free(struct file *file); |
| 22 | extern int ima_file_mmap(struct file *file, unsigned long prot); |
Mimi Zohar | 16c267a | 2018-07-13 14:05:58 -0400 | [diff] [blame] | 23 | extern int ima_load_data(enum kernel_load_data_id id); |
Mimi Zohar | 39eeb4f | 2016-01-30 22:23:26 -0500 | [diff] [blame] | 24 | extern int ima_read_file(struct file *file, enum kernel_read_file_id id); |
Mimi Zohar | cf22221 | 2016-01-14 17:57:47 -0500 | [diff] [blame] | 25 | extern int ima_post_read_file(struct file *file, void *buf, loff_t size, |
| 26 | enum kernel_read_file_id id); |
Mimi Zohar | 05d1a71 | 2016-02-29 19:52:05 -0500 | [diff] [blame] | 27 | extern void ima_post_path_mknod(struct dentry *dentry); |
Mimi Zohar | 3323eec | 2009-02-04 09:06:58 -0500 | [diff] [blame] | 28 | |
Mimi Zohar | 7b8589c | 2016-12-19 16:22:48 -0800 | [diff] [blame] | 29 | #ifdef CONFIG_IMA_KEXEC |
| 30 | extern void ima_add_kexec_buffer(struct kimage *image); |
| 31 | #endif |
| 32 | |
Nayna Jain | 0914ade | 2018-10-09 23:00:33 +0530 | [diff] [blame] | 33 | #ifdef CONFIG_X86 |
| 34 | extern bool arch_ima_get_secureboot(void); |
| 35 | #else |
| 36 | static inline bool arch_ima_get_secureboot(void) |
| 37 | { |
| 38 | return false; |
| 39 | } |
| 40 | #endif |
| 41 | |
Nayna Jain | 6191706 | 2018-10-09 23:00:36 +0530 | [diff] [blame^] | 42 | static inline const char * const *arch_get_ima_policy(void) |
| 43 | { |
| 44 | return NULL; |
| 45 | } |
| 46 | |
Mimi Zohar | 3323eec | 2009-02-04 09:06:58 -0500 | [diff] [blame] | 47 | #else |
Mimi Zohar | 6146f0d | 2009-02-04 09:06:57 -0500 | [diff] [blame] | 48 | static inline int ima_bprm_check(struct linux_binprm *bprm) |
| 49 | { |
| 50 | return 0; |
| 51 | } |
| 52 | |
Al Viro | 6035a27 | 2018-06-08 13:40:10 -0400 | [diff] [blame] | 53 | static inline int ima_file_check(struct file *file, int mask) |
Mimi Zohar | 6146f0d | 2009-02-04 09:06:57 -0500 | [diff] [blame] | 54 | { |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | static inline void ima_file_free(struct file *file) |
| 59 | { |
| 60 | return; |
| 61 | } |
| 62 | |
| 63 | static inline int ima_file_mmap(struct file *file, unsigned long prot) |
| 64 | { |
| 65 | return 0; |
| 66 | } |
Mimi Zohar | 9957a50 | 2011-03-09 22:57:53 -0500 | [diff] [blame] | 67 | |
Mimi Zohar | 16c267a | 2018-07-13 14:05:58 -0400 | [diff] [blame] | 68 | static inline int ima_load_data(enum kernel_load_data_id id) |
| 69 | { |
| 70 | return 0; |
| 71 | } |
| 72 | |
Mimi Zohar | 39eeb4f | 2016-01-30 22:23:26 -0500 | [diff] [blame] | 73 | static inline int ima_read_file(struct file *file, enum kernel_read_file_id id) |
| 74 | { |
| 75 | return 0; |
| 76 | } |
| 77 | |
Mimi Zohar | cf22221 | 2016-01-14 17:57:47 -0500 | [diff] [blame] | 78 | static inline int ima_post_read_file(struct file *file, void *buf, loff_t size, |
| 79 | enum kernel_read_file_id id) |
| 80 | { |
| 81 | return 0; |
| 82 | } |
| 83 | |
Mimi Zohar | 05d1a71 | 2016-02-29 19:52:05 -0500 | [diff] [blame] | 84 | static inline void ima_post_path_mknod(struct dentry *dentry) |
| 85 | { |
| 86 | return; |
| 87 | } |
| 88 | |
Paul Bolle | e05a4f4 | 2013-03-25 21:12:27 +0100 | [diff] [blame] | 89 | #endif /* CONFIG_IMA */ |
Mimi Zohar | 9957a50 | 2011-03-09 22:57:53 -0500 | [diff] [blame] | 90 | |
Mimi Zohar | 7b8589c | 2016-12-19 16:22:48 -0800 | [diff] [blame] | 91 | #ifndef CONFIG_IMA_KEXEC |
| 92 | struct kimage; |
| 93 | |
| 94 | static inline void ima_add_kexec_buffer(struct kimage *image) |
| 95 | {} |
| 96 | #endif |
| 97 | |
Mimi Zohar | 9957a50 | 2011-03-09 22:57:53 -0500 | [diff] [blame] | 98 | #ifdef CONFIG_IMA_APPRAISE |
Mimi Zohar | 6f6723e | 2017-04-24 22:43:52 -0400 | [diff] [blame] | 99 | extern bool is_ima_appraise_enabled(void); |
Mimi Zohar | 9957a50 | 2011-03-09 22:57:53 -0500 | [diff] [blame] | 100 | extern void ima_inode_post_setattr(struct dentry *dentry); |
Mimi Zohar | 42c6333 | 2011-03-10 18:54:15 -0500 | [diff] [blame] | 101 | extern int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name, |
| 102 | const void *xattr_value, size_t xattr_value_len); |
| 103 | extern int ima_inode_removexattr(struct dentry *dentry, const char *xattr_name); |
Mimi Zohar | 9957a50 | 2011-03-09 22:57:53 -0500 | [diff] [blame] | 104 | #else |
Mimi Zohar | 6f6723e | 2017-04-24 22:43:52 -0400 | [diff] [blame] | 105 | static inline bool is_ima_appraise_enabled(void) |
| 106 | { |
| 107 | return 0; |
| 108 | } |
| 109 | |
Mimi Zohar | 9957a50 | 2011-03-09 22:57:53 -0500 | [diff] [blame] | 110 | static inline void ima_inode_post_setattr(struct dentry *dentry) |
| 111 | { |
| 112 | return; |
| 113 | } |
Mimi Zohar | 42c6333 | 2011-03-10 18:54:15 -0500 | [diff] [blame] | 114 | |
| 115 | static inline int ima_inode_setxattr(struct dentry *dentry, |
| 116 | const char *xattr_name, |
| 117 | const void *xattr_value, |
| 118 | size_t xattr_value_len) |
| 119 | { |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | static inline int ima_inode_removexattr(struct dentry *dentry, |
| 124 | const char *xattr_name) |
| 125 | { |
| 126 | return 0; |
| 127 | } |
Paul Bolle | e05a4f4 | 2013-03-25 21:12:27 +0100 | [diff] [blame] | 128 | #endif /* CONFIG_IMA_APPRAISE */ |
Mimi Zohar | 6146f0d | 2009-02-04 09:06:57 -0500 | [diff] [blame] | 129 | #endif /* _LINUX_IMA_H */ |