hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/security/tomoyo/memory.c
....@@ -19,9 +19,9 @@
1919 /* Reduce error messages. */
2020 static pid_t tomoyo_last_pid;
2121 const pid_t pid = current->pid;
22
+
2223 if (tomoyo_last_pid != pid) {
23
- printk(KERN_WARNING "ERROR: Out of memory at %s.\n",
24
- function);
24
+ pr_warn("ERROR: Out of memory at %s.\n", function);
2525 tomoyo_last_pid = pid;
2626 }
2727 if (!tomoyo_policy_loaded)
....@@ -48,6 +48,7 @@
4848 {
4949 if (ptr) {
5050 const size_t s = ksize(ptr);
51
+
5152 tomoyo_memory_used[TOMOYO_MEMORY_POLICY] += s;
5253 if (!tomoyo_memory_quota[TOMOYO_MEMORY_POLICY] ||
5354 tomoyo_memory_used[TOMOYO_MEMORY_POLICY] <=
....@@ -73,6 +74,7 @@
7374 void *tomoyo_commit_ok(void *data, const unsigned int size)
7475 {
7576 void *ptr = kzalloc(size, GFP_NOFS);
77
+
7678 if (tomoyo_memory_ok(ptr)) {
7779 memmove(ptr, data, size);
7880 memset(data, 0, size);
....@@ -98,6 +100,7 @@
98100 struct list_head *list;
99101 const char *group_name = tomoyo_read_token(param);
100102 bool found = false;
103
+
101104 if (!tomoyo_correct_word(group_name) || idx >= TOMOYO_MAX_GROUP)
102105 return NULL;
103106 e.group_name = tomoyo_get_name(group_name);
....@@ -116,6 +119,7 @@
116119 }
117120 if (!found) {
118121 struct tomoyo_group *entry = tomoyo_commit_ok(&e, sizeof(e));
122
+
119123 if (entry) {
120124 INIT_LIST_HEAD(&entry->member_list);
121125 atomic_set(&entry->head.users, 1);
....@@ -191,6 +195,7 @@
191195 void __init tomoyo_mm_init(void)
192196 {
193197 int idx;
198
+
194199 for (idx = 0; idx < TOMOYO_MAX_HASH; idx++)
195200 INIT_LIST_HEAD(&tomoyo_name_list[idx]);
196201 tomoyo_kernel_namespace.name = "<kernel>";