]> Pileus Git - ~andy/linux/blobdiff - security/integrity/ima/ima_template_lib.c
Merge to v3.13-rc7 for prerequisite changes in the Xen code for TPM
[~andy/linux] / security / integrity / ima / ima_template_lib.c
index c2ba481f0f39d5eaae41ec7ed2010fc5b9812427..1683bbf289a407048daad7d4c73154fdb05cfec6 100644 (file)
@@ -109,9 +109,12 @@ static void ima_show_template_data_binary(struct seq_file *m,
                                          enum data_formats datafmt,
                                          struct ima_field_data *field_data)
 {
-       ima_putc(m, &field_data->len, sizeof(u32));
+       if (show != IMA_SHOW_BINARY_NO_FIELD_LEN)
+               ima_putc(m, &field_data->len, sizeof(u32));
+
        if (!field_data->len)
                return;
+
        ima_putc(m, field_data->data, field_data->len);
 }
 
@@ -125,6 +128,7 @@ static void ima_show_template_field_data(struct seq_file *m,
                ima_show_template_data_ascii(m, show, datafmt, field_data);
                break;
        case IMA_SHOW_BINARY:
+       case IMA_SHOW_BINARY_NO_FIELD_LEN:
                ima_show_template_data_binary(m, show, datafmt, field_data);
                break;
        default:
@@ -158,8 +162,7 @@ void ima_show_template_sig(struct seq_file *m, enum ima_show_type show,
 }
 
 static int ima_eventdigest_init_common(u8 *digest, u32 digestsize, u8 hash_algo,
-                                      struct ima_field_data *field_data,
-                                      bool size_limit)
+                                      struct ima_field_data *field_data)
 {
        /*
         * digest formats:
@@ -172,11 +175,10 @@ static int ima_eventdigest_init_common(u8 *digest, u32 digestsize, u8 hash_algo,
        enum data_formats fmt = DATA_FMT_DIGEST;
        u32 offset = 0;
 
-       if (!size_limit) {
+       if (hash_algo < HASH_ALGO__LAST) {
                fmt = DATA_FMT_DIGEST_WITH_ALGO;
-               if (hash_algo < HASH_ALGO__LAST)
-                       offset += snprintf(buffer, CRYPTO_MAX_ALG_NAME + 1,
-                                          "%s", hash_algo_name[hash_algo]);
+               offset += snprintf(buffer, CRYPTO_MAX_ALG_NAME + 1, "%s",
+                                  hash_algo_name[hash_algo]);
                buffer[offset] = ':';
                offset += 2;
        }
@@ -239,8 +241,8 @@ int ima_eventdigest_init(struct integrity_iint_cache *iint, struct file *file,
        cur_digest = hash.hdr.digest;
        cur_digestsize = hash.hdr.length;
 out:
-       return ima_eventdigest_init_common(cur_digest, cur_digestsize, -1,
-                                          field_data, true);
+       return ima_eventdigest_init_common(cur_digest, cur_digestsize,
+                                          HASH_ALGO__LAST, field_data);
 }
 
 /*
@@ -264,7 +266,7 @@ int ima_eventdigest_ng_init(struct integrity_iint_cache *iint,
        hash_algo = iint->ima_hash->algo;
 out:
        return ima_eventdigest_init_common(cur_digest, cur_digestsize,
-                                          hash_algo, field_data, false);
+                                          hash_algo, field_data);
 }
 
 static int ima_eventname_init_common(struct integrity_iint_cache *iint,