diff options
Diffstat (limited to 'security')
| -rw-r--r-- | security/integrity/evm/evm_main.c | 3 | ||||
| -rw-r--r-- | security/integrity/iint.c | 3 | ||||
| -rw-r--r-- | security/integrity/ima/Kconfig | 15 | ||||
| -rw-r--r-- | security/integrity/ima/Makefile | 1 | ||||
| -rw-r--r-- | security/integrity/ima/ima.h | 37 | ||||
| -rw-r--r-- | security/integrity/ima/ima_api.c | 50 | ||||
| -rw-r--r-- | security/integrity/ima/ima_appraise.c | 168 | ||||
| -rw-r--r-- | security/integrity/ima/ima_crypto.c | 8 | ||||
| -rw-r--r-- | security/integrity/ima/ima_main.c | 79 | ||||
| -rw-r--r-- | security/integrity/ima/ima_policy.c | 32 | ||||
| -rw-r--r-- | security/integrity/integrity.h | 8 |
11 files changed, 351 insertions, 53 deletions
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index 8901501425f4..eb5484504f50 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c | |||
| @@ -34,6 +34,9 @@ char *evm_config_xattrnames[] = { | |||
| 34 | #ifdef CONFIG_SECURITY_SMACK | 34 | #ifdef CONFIG_SECURITY_SMACK |
| 35 | XATTR_NAME_SMACK, | 35 | XATTR_NAME_SMACK, |
| 36 | #endif | 36 | #endif |
| 37 | #ifdef CONFIG_IMA_APPRAISE | ||
| 38 | XATTR_NAME_IMA, | ||
| 39 | #endif | ||
| 37 | XATTR_NAME_CAPS, | 40 | XATTR_NAME_CAPS, |
| 38 | NULL | 41 | NULL |
| 39 | }; | 42 | }; |
diff --git a/security/integrity/iint.c b/security/integrity/iint.c index 399641c3e846..e600986aa49f 100644 --- a/security/integrity/iint.c +++ b/security/integrity/iint.c | |||
| @@ -74,6 +74,7 @@ static void iint_free(struct integrity_iint_cache *iint) | |||
| 74 | { | 74 | { |
| 75 | iint->version = 0; | 75 | iint->version = 0; |
| 76 | iint->flags = 0UL; | 76 | iint->flags = 0UL; |
| 77 | iint->ima_status = INTEGRITY_UNKNOWN; | ||
| 77 | iint->evm_status = INTEGRITY_UNKNOWN; | 78 | iint->evm_status = INTEGRITY_UNKNOWN; |
| 78 | kmem_cache_free(iint_cache, iint); | 79 | kmem_cache_free(iint_cache, iint); |
| 79 | } | 80 | } |
| @@ -157,7 +158,7 @@ static void init_once(void *foo) | |||
| 157 | memset(iint, 0, sizeof *iint); | 158 | memset(iint, 0, sizeof *iint); |
| 158 | iint->version = 0; | 159 | iint->version = 0; |
| 159 | iint->flags = 0UL; | 160 | iint->flags = 0UL; |
| 160 | mutex_init(&iint->mutex); | 161 | iint->ima_status = INTEGRITY_UNKNOWN; |
| 161 | iint->evm_status = INTEGRITY_UNKNOWN; | 162 | iint->evm_status = INTEGRITY_UNKNOWN; |
| 162 | } | 163 | } |
| 163 | 164 | ||
diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig index 809ccf19d09c..d232c73647ae 100644 --- a/security/integrity/ima/Kconfig +++ b/security/integrity/ima/Kconfig | |||
| @@ -56,3 +56,18 @@ config IMA_LSM_RULES | |||
| 56 | default y | 56 | default y |
| 57 | help | 57 | help |
| 58 | Disabling this option will disregard LSM based policy rules. | 58 | Disabling this option will disregard LSM based policy rules. |
| 59 | |||
| 60 | config IMA_APPRAISE | ||
| 61 | bool "Appraise integrity measurements" | ||
| 62 | depends on IMA | ||
| 63 | default n | ||
| 64 | help | ||
| 65 | This option enables local measurement integrity appraisal. | ||
| 66 | It requires the system to be labeled with a security extended | ||
| 67 | attribute containing the file hash measurement. To protect | ||
| 68 | the security extended attributes from offline attack, enable | ||
| 69 | and configure EVM. | ||
| 70 | |||
| 71 | For more information on integrity appraisal refer to: | ||
| 72 | <http://linux-ima.sourceforge.net> | ||
| 73 | If unsure, say N. | ||
diff --git a/security/integrity/ima/Makefile b/security/integrity/ima/Makefile index 5f740f6971e1..3f2ca6bdc384 100644 --- a/security/integrity/ima/Makefile +++ b/security/integrity/ima/Makefile | |||
| @@ -8,3 +8,4 @@ obj-$(CONFIG_IMA) += ima.o | |||
| 8 | ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \ | 8 | ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \ |
| 9 | ima_policy.o | 9 | ima_policy.o |
| 10 | ima-$(CONFIG_IMA_AUDIT) += ima_audit.o | 10 | ima-$(CONFIG_IMA_AUDIT) += ima_audit.o |
| 11 | ima-$(CONFIG_IMA_APPRAISE) += ima_appraise.o | ||
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h index e7c99fd0d223..069a4aa63e95 100644 --- a/security/integrity/ima/ima.h +++ b/security/integrity/ima/ima.h | |||
| @@ -40,6 +40,7 @@ enum tpm_pcrs { TPM_PCR0 = 0, TPM_PCR8 = 8 }; | |||
| 40 | extern int ima_initialized; | 40 | extern int ima_initialized; |
| 41 | extern int ima_used_chip; | 41 | extern int ima_used_chip; |
| 42 | extern char *ima_hash; | 42 | extern char *ima_hash; |
| 43 | extern int ima_appraise; | ||
| 43 | 44 | ||
| 44 | /* IMA inode template definition */ | 45 | /* IMA inode template definition */ |
| 45 | struct ima_template_data { | 46 | struct ima_template_data { |
| @@ -107,6 +108,7 @@ static inline unsigned long ima_hash_key(u8 *digest) | |||
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | /* LIM API function definitions */ | 110 | /* LIM API function definitions */ |
| 111 | int ima_must_appraise_or_measure(struct inode *inode, int mask, int function); | ||
| 110 | int ima_must_measure(struct inode *inode, int mask, int function); | 112 | int ima_must_measure(struct inode *inode, int mask, int function); |
| 111 | int ima_collect_measurement(struct integrity_iint_cache *iint, | 113 | int ima_collect_measurement(struct integrity_iint_cache *iint, |
| 112 | struct file *file); | 114 | struct file *file); |
| @@ -123,14 +125,45 @@ struct integrity_iint_cache *integrity_iint_insert(struct inode *inode); | |||
| 123 | struct integrity_iint_cache *integrity_iint_find(struct inode *inode); | 125 | struct integrity_iint_cache *integrity_iint_find(struct inode *inode); |
| 124 | 126 | ||
| 125 | /* IMA policy related functions */ | 127 | /* IMA policy related functions */ |
| 126 | enum ima_hooks { FILE_CHECK = 1, FILE_MMAP, BPRM_CHECK }; | 128 | enum ima_hooks { FILE_CHECK = 1, FILE_MMAP, BPRM_CHECK, POST_SETATTR }; |
| 127 | 129 | ||
| 128 | int ima_match_policy(struct inode *inode, enum ima_hooks func, int mask); | 130 | int ima_match_policy(struct inode *inode, enum ima_hooks func, int mask, |
| 131 | int flags); | ||
| 129 | void ima_init_policy(void); | 132 | void ima_init_policy(void); |
| 130 | void ima_update_policy(void); | 133 | void ima_update_policy(void); |
| 131 | ssize_t ima_parse_add_rule(char *); | 134 | ssize_t ima_parse_add_rule(char *); |
| 132 | void ima_delete_rules(void); | 135 | void ima_delete_rules(void); |
| 133 | 136 | ||
| 137 | /* Appraise integrity measurements */ | ||
| 138 | #define IMA_APPRAISE_ENFORCE 0x01 | ||
| 139 | #define IMA_APPRAISE_FIX 0x02 | ||
| 140 | |||
| 141 | #ifdef CONFIG_IMA_APPRAISE | ||
| 142 | int ima_appraise_measurement(struct integrity_iint_cache *iint, | ||
| 143 | struct file *file, const unsigned char *filename); | ||
| 144 | int ima_must_appraise(struct inode *inode, enum ima_hooks func, int mask); | ||
| 145 | void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file); | ||
| 146 | |||
| 147 | #else | ||
| 148 | static inline int ima_appraise_measurement(struct integrity_iint_cache *iint, | ||
| 149 | struct file *file, | ||
| 150 | const unsigned char *filename) | ||
| 151 | { | ||
| 152 | return INTEGRITY_UNKNOWN; | ||
| 153 | } | ||
| 154 | |||
| 155 | static inline int ima_must_appraise(struct inode *inode, | ||
| 156 | enum ima_hooks func, int mask) | ||
| 157 | { | ||
| 158 | return 0; | ||
| 159 | } | ||
| 160 | |||
| 161 | static inline void ima_update_xattr(struct integrity_iint_cache *iint, | ||
| 162 | struct file *file) | ||
| 163 | { | ||
| 164 | } | ||
| 165 | #endif | ||
| 166 | |||
| 134 | /* LSM based policy rules require audit */ | 167 | /* LSM based policy rules require audit */ |
| 135 | #ifdef CONFIG_IMA_LSM_RULES | 168 | #ifdef CONFIG_IMA_LSM_RULES |
| 136 | 169 | ||
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c index 032ff03ad907..41cce84416c5 100644 --- a/security/integrity/ima/ima_api.c +++ b/security/integrity/ima/ima_api.c | |||
| @@ -9,13 +9,17 @@ | |||
| 9 | * License. | 9 | * License. |
| 10 | * | 10 | * |
| 11 | * File: ima_api.c | 11 | * File: ima_api.c |
| 12 | * Implements must_measure, collect_measurement, store_measurement, | 12 | * Implements must_appraise_or_measure, collect_measurement, |
| 13 | * and store_template. | 13 | * appraise_measurement, store_measurement and store_template. |
| 14 | */ | 14 | */ |
| 15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
| 17 | 17 | #include <linux/file.h> | |
| 18 | #include <linux/fs.h> | ||
| 19 | #include <linux/xattr.h> | ||
| 20 | #include <linux/evm.h> | ||
| 18 | #include "ima.h" | 21 | #include "ima.h" |
| 22 | |||
| 19 | static const char *IMA_TEMPLATE_NAME = "ima"; | 23 | static const char *IMA_TEMPLATE_NAME = "ima"; |
| 20 | 24 | ||
| 21 | /* | 25 | /* |
| @@ -93,7 +97,7 @@ err_out: | |||
| 93 | } | 97 | } |
| 94 | 98 | ||
| 95 | /** | 99 | /** |
| 96 | * ima_must_measure - measure decision based on policy. | 100 | * ima_must_appraise_or_measure - appraise & measure decision based on policy. |
| 97 | * @inode: pointer to inode to measure | 101 | * @inode: pointer to inode to measure |
| 98 | * @mask: contains the permission mask (MAY_READ, MAY_WRITE, MAY_EXECUTE) | 102 | * @mask: contains the permission mask (MAY_READ, MAY_WRITE, MAY_EXECUTE) |
| 99 | * @function: call | ||
