aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/tomoyo/memory.c')
-rw-r--r--security/tomoyo/memory.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/security/tomoyo/memory.c b/security/tomoyo/memory.c
index 12477e0b0a11..2e7fcfa923c9 100644
--- a/security/tomoyo/memory.c
+++ b/security/tomoyo/memory.c
@@ -19,9 +19,9 @@ void tomoyo_warn_oom(const char *function)
19 /* Reduce error messages. */ 19 /* Reduce error messages. */
20 static pid_t tomoyo_last_pid; 20 static pid_t tomoyo_last_pid;
21 const pid_t pid = current->pid; 21 const pid_t pid = current->pid;
22
22 if (tomoyo_last_pid != pid) { 23 if (tomoyo_last_pid != pid) {
23 printk(KERN_WARNING "ERROR: Out of memory at %s.\n", 24 pr_warn("ERROR: Out of memory at %s.\n", function);
24 function);
25 tomoyo_last_pid = pid; 25 tomoyo_last_pid = pid;
26 } 26 }
27 if (!tomoyo_policy_loaded) 27 if (!tomoyo_policy_loaded)
@@ -48,6 +48,7 @@ bool tomoyo_memory_ok(void *ptr)
48{ 48{
49 if (ptr) { 49 if (ptr) {
50 const size_t s = ksize(ptr); 50 const size_t s = ksize(ptr);
51
51 tomoyo_memory_used[TOMOYO_MEMORY_POLICY] += s; 52 tomoyo_memory_used[TOMOYO_MEMORY_POLICY] += s;
52 if (!tomoyo_memory_quota[TOMOYO_MEMORY_POLICY] || 53 if (!tomoyo_memory_quota[TOMOYO_MEMORY_POLICY] ||
53 tomoyo_memory_used[TOMOYO_MEMORY_POLICY] <= 54 tomoyo_memory_used[TOMOYO_MEMORY_POLICY] <=
@@ -73,6 +74,7 @@ bool tomoyo_memory_ok(void *ptr)
73void *tomoyo_commit_ok(void *data, const unsigned int size) 74void *tomoyo_commit_ok(void *data, const unsigned int size)
74{ 75{
75 void *ptr = kzalloc(size, GFP_NOFS); 76 void *ptr = kzalloc(size, GFP_NOFS);
77
76 if (tomoyo_memory_ok(ptr)) { 78 if (tomoyo_memory_ok(ptr)) {
77 memmove(ptr, data, size); 79 memmove(ptr, data, size);
78 memset(data, 0, size); 80 memset(data, 0, size);
@@ -98,6 +100,7 @@ struct tomoyo_group *tomoyo_get_group(struct tomoyo_acl_param *param,
98 struct list_head *list; 100 struct list_head *list;
99 const char *group_name = tomoyo_read_token(param); 101 const char *group_name = tomoyo_read_token(param);
100 bool found = false; 102 bool found = false;
103
101 if (!tomoyo_correct_word(group_name) || idx >= TOMOYO_MAX_GROUP) 104 if (!tomoyo_correct_word(group_name) || idx >= TOMOYO_MAX_GROUP)
102 return NULL; 105 return NULL;
103 e.group_name = tomoyo_get_name(group_name); 106 e.group_name = tomoyo_get_name(group_name);
@@ -116,6 +119,7 @@ struct tomoyo_group *tomoyo_get_group(struct tomoyo_acl_param *param,
116 } 119 }
117 if (!found) { 120 if (!found) {
118 struct tomoyo_group *entry = tomoyo_commit_ok(&e, sizeof(e)); 121 struct tomoyo_group *entry = tomoyo_commit_ok(&e, sizeof(e));
122
119 if (entry) { 123 if (entry) {
120 INIT_LIST_HEAD(&entry->member_list); 124 INIT_LIST_HEAD(&entry->member_list);
121 atomic_set(&entry->head.users, 1); 125 atomic_set(&entry->head.users, 1);
@@ -191,6 +195,7 @@ struct tomoyo_policy_namespace tomoyo_kernel_namespace;
191void __init tomoyo_mm_init(void) 195void __init tomoyo_mm_init(void)
192{ 196{
193 int idx; 197 int idx;
198
194 for (idx = 0; idx < TOMOYO_MAX_HASH; idx++) 199 for (idx = 0; idx < TOMOYO_MAX_HASH; idx++)
195 INIT_LIST_HEAD(&tomoyo_name_list[idx]); 200 INIT_LIST_HEAD(&tomoyo_name_list[idx]);
196 tomoyo_kernel_namespace.name = "<kernel>"; 201 tomoyo_kernel_namespace.name = "<kernel>";