aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-09-07 16:22:23 -0400
committerMimi Zohar <zohar@linux.ibm.com>2018-10-10 12:56:15 -0400
commitb2724d5802a77b7fb47e84d9b88b80370eccbc64 (patch)
tree59917073de892c95ac1b59b3ae8c31f2ecf76749
parent691115c3513ec83edf68ba6575ae85630bc94b8b (diff)
security/integrity: constify some read-only data
Constify some static data that is never modified, so that it is placed in .rodata. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
-rw-r--r--security/integrity/digsig.c2
-rw-r--r--security/integrity/evm/evm_crypto.c4
-rw-r--r--security/integrity/ima/ima.h2
-rw-r--r--security/integrity/ima/ima_api.c3
-rw-r--r--security/integrity/ima/ima_fs.c3
-rw-r--r--security/integrity/ima/ima_init.c2
-rw-r--r--security/integrity/ima/ima_main.c2
-rw-r--r--security/integrity/ima/ima_template.c11
8 files changed, 16 insertions, 13 deletions
diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c
index 9bb0a7f2863e..879396fa3be0 100644
--- a/security/integrity/digsig.c
+++ b/security/integrity/digsig.c
@@ -26,7 +26,7 @@
26 26
27static struct key *keyring[INTEGRITY_KEYRING_MAX]; 27static struct key *keyring[INTEGRITY_KEYRING_MAX];
28 28
29static const char *keyring_name[INTEGRITY_KEYRING_MAX] = { 29static const char * const keyring_name[INTEGRITY_KEYRING_MAX] = {
30#ifndef CONFIG_INTEGRITY_TRUSTED_KEYRING 30#ifndef CONFIG_INTEGRITY_TRUSTED_KEYRING
31 "_evm", 31 "_evm",
32 "_ima", 32 "_ima",
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index 8a3905bb02c7..8c25f949ebdb 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -27,7 +27,7 @@
27#define EVMKEY "evm-key" 27#define EVMKEY "evm-key"
28#define MAX_KEY_SIZE 128 28#define MAX_KEY_SIZE 128
29static unsigned char evmkey[MAX_KEY_SIZE]; 29static unsigned char evmkey[MAX_KEY_SIZE];
30static int evmkey_len = MAX_KEY_SIZE; 30static const int evmkey_len = MAX_KEY_SIZE;
31 31
32struct crypto_shash *hmac_tfm; 32struct crypto_shash *hmac_tfm;
33static struct crypto_shash *evm_tfm[HASH_ALGO__LAST]; 33static struct crypto_shash *evm_tfm[HASH_ALGO__LAST];
@@ -38,7 +38,7 @@ static DEFINE_MUTEX(mutex);
38 38
39static unsigned long evm_set_key_flags; 39static unsigned long evm_set_key_flags;
40 40
41static char * const evm_hmac = "hmac(sha1)"; 41static const char evm_hmac[] = "hmac(sha1)";
42 42
43/** 43/**
44 * evm_set_key() - set EVM HMAC key from the kernel 44 * evm_set_key() - set EVM HMAC key from the kernel
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index 67db9d9454ca..cc12f3449a72 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -88,7 +88,7 @@ struct ima_template_desc {
88 char *name; 88 char *name;
89 char *fmt; 89 char *fmt;
90 int num_fields; 90 int num_fields;
91 struct ima_template_field **fields; 91 const struct ima_template_field **fields;
92}; 92};
93 93
94struct ima_template_entry { 94struct ima_template_entry {
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index a02c5acfd403..99dd1d53fc35 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -51,7 +51,8 @@ int ima_alloc_init_template(struct ima_event_data *event_data,
51 51
52 (*entry)->template_desc = template_desc; 52 (*entry)->template_desc = template_desc;
53 for (i = 0; i < template_desc->num_fields; i++) { 53 for (i = 0; i < template_desc->num_fields; i++) {
54 struct ima_template_field *field = template_desc->fields[i]; 54 const struct ima_template_field *field =
55 template_desc->fields[i];
55 u32 len; 56 u32 len;
56 57
57 result = field->field_init(event_data, 58 result = field->field_init(event_data,
diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
index ae9d5c766a3c..fe0ede883557 100644
--- a/security/integrity/ima/ima_fs.c
+++ b/security/integrity/ima/ima_fs.c
@@ -179,7 +179,8 @@ int ima_measurements_show(struct seq_file *m, void *v)
179 /* 6th: template specific data */ 179 /* 6th: template specific data */
180 for (i = 0; i < e->template_desc->num_fields; i++) { 180 for (i = 0; i < e->template_desc->num_fields; i++) {
181 enum ima_show_type show = IMA_SHOW_BINARY; 181 enum ima_show_type show = IMA_SHOW_BINARY;
182 struct ima_template_field *field = e->template_desc->fields[i]; 182 const struct ima_template_field *field =
183 e->template_desc->fields[i];
183 184
184 if (is_ima_template && strcmp(field->field_id, "d") == 0) 185 if (is_ima_template && strcmp(field->field_id, "d") == 0)
185 show = IMA_SHOW_BINARY_NO_FIELD_LEN; 186 show = IMA_SHOW_BINARY_NO_FIELD_LEN;
diff --git a/security/integrity/ima/ima_init.c b/security/integrity/ima/ima_init.c
index faac9ecaa0ae..59d834219cd6 100644
--- a/security/integrity/ima/ima_init.c
+++ b/security/integrity/ima/ima_init.c
@@ -25,7 +25,7 @@
25#include "ima.h" 25#include "ima.h"
26 26
27/* name for boot aggregate entry */ 27/* name for boot aggregate entry */
28static const char *boot_aggregate_name = "boot_aggregate"; 28static const char boot_aggregate_name[] = "boot_aggregate";
29struct tpm_chip *ima_tpm_chip; 29struct tpm_chip *ima_tpm_chip;
30 30
31/* Add the boot aggregate to the IMA measurement list and extend 31/* Add the boot aggregate to the IMA measurement list and extend
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 2d31921fbda4..1b88d58e1325 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -440,7 +440,7 @@ int ima_read_file(struct file *file, enum kernel_read_file_id read_id)
440 return 0; 440 return 0;
441} 441}
442 442
443static int read_idmap[READING_MAX_ID] = { 443static const int read_idmap[READING_MAX_ID] = {
444 [READING_FIRMWARE] = FIRMWARE_CHECK, 444 [READING_FIRMWARE] = FIRMWARE_CHECK,
445 [READING_FIRMWARE_PREALLOC_BUFFER] = FIRMWARE_CHECK, 445 [READING_FIRMWARE_PREALLOC_BUFFER] = FIRMWARE_CHECK,
446 [READING_MODULE] = MODULE_CHECK, 446 [READING_MODULE] = MODULE_CHECK,
diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index 30db39b23804..b631b8bc7624 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -32,7 +32,7 @@ static struct ima_template_desc builtin_templates[] = {
32static LIST_HEAD(defined_templates); 32static LIST_HEAD(defined_templates);
33static DEFINE_SPINLOCK(template_list); 33static DEFINE_SPINLOCK(template_list);
34 34
35static struct ima_template_field supported_fields[] = { 35static const struct ima_template_field supported_fields[] = {
36 {.field_id = "d", .field_init = ima_eventdigest_init, 36 {.field_id = "d", .field_init = ima_eventdigest_init,
37 .field_show = ima_show_template_digest}, 37 .field_show = ima_show_template_digest},
38 {.field_id = "n", .field_init = ima_eventname_init, 38 {.field_id = "n", .field_init = ima_eventname_init,
@@ -49,7 +49,7 @@ static struct ima_template_field supported_fields[] = {
49static struct ima_template_desc *ima_template; 49static struct ima_template_desc *ima_template;
50static struct ima_template_desc *lookup_template_desc(const char *name); 50static struct ima_template_desc *lookup_template_desc(const char *name);
51static int template_desc_init_fields(const char *template_fmt, 51static int template_desc_init_fields(const char *template_fmt,
52 struct ima_template_field ***fields, 52 const struct ima_template_field ***fields,
53 int *num_fields); 53 int *num_fields);
54 54
55static int __init ima_template_setup(char *str) 55static int __init ima_template_setup(char *str)
@@ -125,7 +125,8 @@ static struct ima_template_desc *lookup_template_desc(const char *name)
125 return found ? template_desc : NULL; 125 return found ? template_desc : NULL;
126} 126}
127 127
128static struct ima_template_field *lookup_template_field(const char *field_id) 128static const struct ima_template_field *
129lookup_template_field(const char *field_id)
129{ 130{
130 int i; 131 int i;
131 132
@@ -153,11 +154,11 @@ static int template_fmt_size(const char *template_fmt)
153} 154}
154 155
155static int template_desc_init_fields(const char *template_fmt, 156static int template_desc_init_fields(const char *template_fmt,
156 struct ima_template_field ***fields, 157 const struct ima_template_field ***fields,
157 int *num_fields) 158 int *num_fields)
158{ 159{
159 const char *template_fmt_ptr; 160 const char *template_fmt_ptr;
160 struct ima_template_field *found_fields[IMA_TEMPLATE_NUM_FIELDS_MAX]; 161 const struct ima_template_field *found_fields[IMA_TEMPLATE_NUM_FIELDS_MAX];
161 int template_num_fields; 162 int template_num_fields;
162 int i, len; 163 int i, len;
163 164