diff options
author | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2015-11-19 12:39:22 -0500 |
---|---|---|
committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2016-02-21 09:06:13 -0500 |
commit | c6af8efe97d87fa308eb1bbd0cf4feb820a4d622 (patch) | |
tree | 7a7ea8e33a28b7b47ec7c6fa16e14c6838b269ff /security | |
parent | a1db74209483a24c861c848b4bb79a4d945ef6fa (diff) |
ima: remove firmware and module specific cached status info
Each time a file is read by the kernel, the file should be re-measured and
the file signature re-appraised, based on policy. As there is no need to
preserve the status information, this patch replaces the firmware and
module specific cache status with a generic one named read_file.
This change simplifies adding support for other files read by the kernel.
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Acked-by: Petko Manolov <petkan@mip-labs.com>
Acked-by: Dmitry Kasatkin <dmitry.kasatkin@huawei.com>
Diffstat (limited to 'security')
-rw-r--r-- | security/integrity/iint.c | 4 | ||||
-rw-r--r-- | security/integrity/ima/ima.h | 3 | ||||
-rw-r--r-- | security/integrity/ima/ima_appraise.c | 35 | ||||
-rw-r--r-- | security/integrity/ima/ima_policy.c | 9 | ||||
-rw-r--r-- | security/integrity/integrity.h | 16 |
5 files changed, 28 insertions, 39 deletions
diff --git a/security/integrity/iint.c b/security/integrity/iint.c index 8f1ab37f2897..345b75997e4c 100644 --- a/security/integrity/iint.c +++ b/security/integrity/iint.c | |||
@@ -77,7 +77,7 @@ static void iint_free(struct integrity_iint_cache *iint) | |||
77 | iint->ima_file_status = INTEGRITY_UNKNOWN; | 77 | iint->ima_file_status = INTEGRITY_UNKNOWN; |
78 | iint->ima_mmap_status = INTEGRITY_UNKNOWN; | 78 | iint->ima_mmap_status = INTEGRITY_UNKNOWN; |
79 | iint->ima_bprm_status = INTEGRITY_UNKNOWN; | 79 | iint->ima_bprm_status = INTEGRITY_UNKNOWN; |
80 | iint->ima_module_status = INTEGRITY_UNKNOWN; | 80 | iint->ima_read_status = INTEGRITY_UNKNOWN; |
81 | iint->evm_status = INTEGRITY_UNKNOWN; | 81 | iint->evm_status = INTEGRITY_UNKNOWN; |
82 | kmem_cache_free(iint_cache, iint); | 82 | kmem_cache_free(iint_cache, iint); |
83 | } | 83 | } |
@@ -157,7 +157,7 @@ static void init_once(void *foo) | |||
157 | iint->ima_file_status = INTEGRITY_UNKNOWN; | 157 | iint->ima_file_status = INTEGRITY_UNKNOWN; |
158 | iint->ima_mmap_status = INTEGRITY_UNKNOWN; | 158 | iint->ima_mmap_status = INTEGRITY_UNKNOWN; |
159 | iint->ima_bprm_status = INTEGRITY_UNKNOWN; | 159 | iint->ima_bprm_status = INTEGRITY_UNKNOWN; |
160 | iint->ima_module_status = INTEGRITY_UNKNOWN; | 160 | iint->ima_read_status = INTEGRITY_UNKNOWN; |
161 | iint->evm_status = INTEGRITY_UNKNOWN; | 161 | iint->evm_status = INTEGRITY_UNKNOWN; |
162 | } | 162 | } |
163 | 163 | ||
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h index 0b7134c04165..a5d25921ee3c 100644 --- a/security/integrity/ima/ima.h +++ b/security/integrity/ima/ima.h | |||
@@ -144,9 +144,10 @@ enum ima_hooks { | |||
144 | FILE_CHECK = 1, | 144 | FILE_CHECK = 1, |
145 | MMAP_CHECK, | 145 | MMAP_CHECK, |
146 | BPRM_CHECK, | 146 | BPRM_CHECK, |
147 | POST_SETATTR, | ||
147 | MODULE_CHECK, | 148 | MODULE_CHECK, |
148 | FIRMWARE_CHECK, | 149 | FIRMWARE_CHECK, |
149 | POST_SETATTR | 150 | MAX_CHECK |
150 | }; | 151 | }; |
151 | 152 | ||
152 | /* LIM API function definitions */ | 153 | /* LIM API function definitions */ |
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c index cb0d0ff1137b..6b4694aedae8 100644 --- a/security/integrity/ima/ima_appraise.c +++ b/security/integrity/ima/ima_appraise.c | |||
@@ -74,13 +74,12 @@ enum integrity_status ima_get_cache_status(struct integrity_iint_cache *iint, | |||
74 | return iint->ima_mmap_status; | 74 | return iint->ima_mmap_status; |
75 | case BPRM_CHECK: | 75 | case BPRM_CHECK: |
76 | return iint->ima_bprm_status; | 76 | return iint->ima_bprm_status; |
77 | case MODULE_CHECK: | ||
78 | return iint->ima_module_status; | ||
79 | case FIRMWARE_CHECK: | ||
80 | return iint->ima_firmware_status; | ||
81 | case FILE_CHECK: | 77 | case FILE_CHECK: |
82 | default: | 78 | case POST_SETATTR: |
83 | return iint->ima_file_status; | 79 | return iint->ima_file_status; |
80 | case MODULE_CHECK ... MAX_CHECK - 1: | ||
81 | default: | ||
82 | return iint->ima_read_status; | ||
84 | } | 83 | } |
85 | } | 84 | } |
86 | 85 | ||
@@ -95,15 +94,14 @@ static void ima_set_cache_status(struct integrity_iint_cache *iint, | |||
95 | case BPRM_CHECK: | 94 | case BPRM_CHECK: |
96 | iint->ima_bprm_status = status; | 95 | iint->ima_bprm_status = status; |
97 | break; | 96 | break; |
98 | case MODULE_CHECK: | ||
99 | iint->ima_module_status = status; | ||
100 | break; | ||
101 | case FIRMWARE_CHECK: | ||
102 | iint->ima_firmware_status = status; | ||
103 | break; | ||
104 | case FILE_CHECK: | 97 | case FILE_CHECK: |
105 | default: | 98 | case POST_SETATTR: |
106 | iint->ima_file_status = status; | 99 | iint->ima_file_status = status; |
100 | break; | ||
101 | case MODULE_CHECK ... MAX_CHECK - 1: | ||
102 | default: | ||
103 | iint->ima_read_status = status; | ||
104 | break; | ||
107 | } | 105 | } |
108 | } | 106 | } |
109 | 107 | ||
@@ -117,15 +115,14 @@ static void ima_cache_flags(struct integrity_iint_cache *iint, | |||
117 | case BPRM_CHECK: | 115 | case BPRM_CHECK: |
118 | iint->flags |= (IMA_BPRM_APPRAISED | IMA_APPRAISED); | 116 | iint->flags |= (IMA_BPRM_APPRAISED | IMA_APPRAISED); |
119 | break; | 117 | break; |
120 | case MODULE_CHECK: | ||
121 | iint->flags |= (IMA_MODULE_APPRAISED | IMA_APPRAISED); | ||
122 | break; | ||
123 | case FIRMWARE_CHECK: | ||
124 | iint->flags |= (IMA_FIRMWARE_APPRAISED | IMA_APPRAISED); | ||
125 | break; | ||
126 | case FILE_CHECK: | 118 | case FILE_CHECK: |
127 | default: | 119 | case POST_SETATTR: |
128 | iint->flags |= (IMA_FILE_APPRAISED | IMA_APPRAISED); | 120 | iint->flags |= (IMA_FILE_APPRAISED | IMA_APPRAISED); |
121 | break; | ||
122 | case MODULE_CHECK ... MAX_CHECK - 1: | ||
123 | default: | ||
124 | iint->flags |= (IMA_READ_APPRAISED | IMA_APPRAISED); | ||
125 | break; | ||
129 | } | 126 | } |
130 | } | 127 | } |
131 | 128 | ||
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index cfbe86f476d0..7571ce8841ff 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c | |||
@@ -300,13 +300,12 @@ static int get_subaction(struct ima_rule_entry *rule, enum ima_hooks func) | |||
300 | return IMA_MMAP_APPRAISE; | 300 | return IMA_MMAP_APPRAISE; |
301 | case BPRM_CHECK: | 301 | case BPRM_CHECK: |
302 | return IMA_BPRM_APPRAISE; | 302 | return IMA_BPRM_APPRAISE; |
303 | case MODULE_CHECK: | ||
304 | return IMA_MODULE_APPRAISE; | ||
305 | case FIRMWARE_CHECK: | ||
306 | return IMA_FIRMWARE_APPRAISE; | ||
307 | case FILE_CHECK: | 303 | case FILE_CHECK: |
308 | default: | 304 | case POST_SETATTR: |
309 | return IMA_FILE_APPRAISE; | 305 | return IMA_FILE_APPRAISE; |
306 | case MODULE_CHECK ... MAX_CHECK - 1: | ||
307 | default: | ||
308 | return IMA_READ_APPRAISE; | ||
310 | } | 309 | } |
311 | } | 310 | } |
312 | 311 | ||
diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h index 9a0ea4c4e3dd..c7a111cc7d89 100644 --- a/security/integrity/integrity.h +++ b/security/integrity/integrity.h | |||
@@ -45,18 +45,12 @@ | |||
45 | #define IMA_MMAP_APPRAISED 0x00000800 | 45 | #define IMA_MMAP_APPRAISED 0x00000800 |
46 | #define IMA_BPRM_APPRAISE 0x00001000 | 46 | #define IMA_BPRM_APPRAISE 0x00001000 |
47 | #define IMA_BPRM_APPRAISED 0x00002000 | 47 | #define IMA_BPRM_APPRAISED 0x00002000 |
48 | #define IMA_MODULE_APPRAISE 0x00004000 | 48 | #define IMA_READ_APPRAISE 0x00004000 |
49 | #define IMA_MODULE_APPRAISED 0x00008000 | 49 | #define IMA_READ_APPRAISED 0x00008000 |
50 | #define IMA_FIRMWARE_APPRAISE 0x00010000 | ||
51 | #define IMA_FIRMWARE_APPRAISED 0x00020000 | ||
52 | #define IMA_READ_APPRAISE 0x00040000 | ||
53 | #define IMA_READ_APPRAISED 0x00080000 | ||
54 | #define IMA_APPRAISE_SUBMASK (IMA_FILE_APPRAISE | IMA_MMAP_APPRAISE | \ | 50 | #define IMA_APPRAISE_SUBMASK (IMA_FILE_APPRAISE | IMA_MMAP_APPRAISE | \ |
55 | IMA_BPRM_APPRAISE | IMA_MODULE_APPRAISE | \ | 51 | IMA_BPRM_APPRAISE | IMA_READ_APPRAISE) |
56 | IMA_FIRMWARE_APPRAISE | IMA_READ_APPRAISE) | ||
57 | #define IMA_APPRAISED_SUBMASK (IMA_FILE_APPRAISED | IMA_MMAP_APPRAISED | \ | 52 | #define IMA_APPRAISED_SUBMASK (IMA_FILE_APPRAISED | IMA_MMAP_APPRAISED | \ |
58 | IMA_BPRM_APPRAISED | IMA_MODULE_APPRAISED | \ | 53 | IMA_BPRM_APPRAISED | IMA_READ_APPRAISED) |
59 | IMA_FIRMWARE_APPRAISED | IMA_READ_APPRAISED) | ||
60 | 54 | ||
61 | enum evm_ima_xattr_type { | 55 | enum evm_ima_xattr_type { |
62 | IMA_XATTR_DIGEST = 0x01, | 56 | IMA_XATTR_DIGEST = 0x01, |
@@ -111,8 +105,6 @@ struct integrity_iint_cache { | |||
111 | enum integrity_status ima_file_status:4; | 105 | enum integrity_status ima_file_status:4; |
112 | enum integrity_status ima_mmap_status:4; | 106 | enum integrity_status ima_mmap_status:4; |
113 | enum integrity_status ima_bprm_status:4; | 107 | enum integrity_status ima_bprm_status:4; |
114 | enum integrity_status ima_module_status:4; | ||
115 | enum integrity_status ima_firmware_status:4; | ||
116 | enum integrity_status ima_read_status:4; | 108 | enum integrity_status ima_read_status:4; |
117 | enum integrity_status evm_status:4; | 109 | enum integrity_status evm_status:4; |
118 | struct ima_digest_data *ima_hash; | 110 | struct ima_digest_data *ima_hash; |