diff options
author | Roberto Sassu <roberto.sassu@polito.it> | 2013-11-08 13:21:37 -0500 |
---|---|---|
committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2014-01-03 07:43:00 -0500 |
commit | dcf4e392867bf98d50ad108ed7c2bfb941e8c33d (patch) | |
tree | 25f5668c6acf31bcb593937acac3673b350a942e /security/integrity | |
parent | ef8894b0ca3f123bd68dd748b162369ccbeca4a7 (diff) |
ima: remove unneeded size_limit argument from ima_eventdigest_init_common()
This patch removes the 'size_limit' argument from
ima_eventdigest_init_common(). Since the 'd' field will never include
the hash algorithm as prefix and the 'd-ng' will always have it, we can
use the hash algorithm to differentiate the two cases in the modified
function (it is equal to HASH_ALGO__LAST in the first case, the opposite
in the second).
Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Diffstat (limited to 'security/integrity')
-rw-r--r-- | security/integrity/ima/ima_template_lib.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/security/integrity/ima/ima_template_lib.c b/security/integrity/ima/ima_template_lib.c index 4752a539f69a..6d01c694a32c 100644 --- a/security/integrity/ima/ima_template_lib.c +++ b/security/integrity/ima/ima_template_lib.c | |||
@@ -158,8 +158,7 @@ void ima_show_template_sig(struct seq_file *m, enum ima_show_type show, | |||
158 | } | 158 | } |
159 | 159 | ||
160 | static int ima_eventdigest_init_common(u8 *digest, u32 digestsize, u8 hash_algo, | 160 | static int ima_eventdigest_init_common(u8 *digest, u32 digestsize, u8 hash_algo, |
161 | struct ima_field_data *field_data, | 161 | struct ima_field_data *field_data) |
162 | bool size_limit) | ||
163 | { | 162 | { |
164 | /* | 163 | /* |
165 | * digest formats: | 164 | * digest formats: |
@@ -172,11 +171,10 @@ static int ima_eventdigest_init_common(u8 *digest, u32 digestsize, u8 hash_algo, | |||
172 | enum data_formats fmt = DATA_FMT_DIGEST; | 171 | enum data_formats fmt = DATA_FMT_DIGEST; |
173 | u32 offset = 0; | 172 | u32 offset = 0; |
174 | 173 | ||
175 | if (!size_limit) { | 174 | if (hash_algo < HASH_ALGO__LAST) { |
176 | fmt = DATA_FMT_DIGEST_WITH_ALGO; | 175 | fmt = DATA_FMT_DIGEST_WITH_ALGO; |
177 | if (hash_algo < HASH_ALGO__LAST) | 176 | offset += snprintf(buffer, CRYPTO_MAX_ALG_NAME + 1, "%s", |
178 | offset += snprintf(buffer, CRYPTO_MAX_ALG_NAME + 1, | 177 | hash_algo_name[hash_algo]); |
179 | "%s", hash_algo_name[hash_algo]); | ||
180 | buffer[offset] = ':'; | 178 | buffer[offset] = ':'; |
181 | offset += 2; | 179 | offset += 2; |
182 | } | 180 | } |
@@ -240,7 +238,7 @@ int ima_eventdigest_init(struct integrity_iint_cache *iint, struct file *file, | |||
240 | cur_digestsize = hash.hdr.length; | 238 | cur_digestsize = hash.hdr.length; |
241 | out: | 239 | out: |
242 | return ima_eventdigest_init_common(cur_digest, cur_digestsize, | 240 | return ima_eventdigest_init_common(cur_digest, cur_digestsize, |
243 | HASH_ALGO__LAST, field_data, true); | 241 | HASH_ALGO__LAST, field_data); |
244 | } | 242 | } |
245 | 243 | ||
246 | /* | 244 | /* |
@@ -264,7 +262,7 @@ int ima_eventdigest_ng_init(struct integrity_iint_cache *iint, | |||
264 | hash_algo = iint->ima_hash->algo; | 262 | hash_algo = iint->ima_hash->algo; |
265 | out: | 263 | out: |
266 | return ima_eventdigest_init_common(cur_digest, cur_digestsize, | 264 | return ima_eventdigest_init_common(cur_digest, cur_digestsize, |
267 | hash_algo, field_data, false); | 265 | hash_algo, field_data); |
268 | } | 266 | } |
269 | 267 | ||
270 | static int ima_eventname_init_common(struct integrity_iint_cache *iint, | 268 | static int ima_eventname_init_common(struct integrity_iint_cache *iint, |