aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/util.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-27 22:26:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-27 22:26:38 -0400
commit95b6886526bb510b8370b625a49bc0ab3b8ff10f (patch)
tree2862606224820d200be12d2092dcd26df1654b80 /security/tomoyo/util.c
parent22712200e175e0df5c7f9edfe6c6bf5c94c23b83 (diff)
parent29412f0f6a19e34336368f13eab848091c343952 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6: (54 commits) tpm_nsc: Fix bug when loading multiple TPM drivers tpm: Move tpm_tis_reenable_interrupts out of CONFIG_PNP block tpm: Fix compilation warning when CONFIG_PNP is not defined TOMOYO: Update kernel-doc. tpm: Fix a typo tpm_tis: Probing function for Intel iTPM bug tpm_tis: Fix the probing for interrupts tpm_tis: Delay ACPI S3 suspend while the TPM is busy tpm_tis: Re-enable interrupts upon (S3) resume tpm: Fix display of data in pubek sysfs entry tpm_tis: Add timeouts sysfs entry tpm: Adjust interface timeouts if they are too small tpm: Use interface timeouts returned from the TPM tpm_tis: Introduce durations sysfs entry tpm: Adjust the durations if they are too small tpm: Use durations returned from TPM TOMOYO: Enable conditional ACL. TOMOYO: Allow using argv[]/envp[] of execve() as conditions. TOMOYO: Allow using executable's realpath and symlink's target as conditions. TOMOYO: Allow using owner/group etc. of file objects as conditions. ... Fix up trivial conflict in security/tomoyo/realpath.c
Diffstat (limited to 'security/tomoyo/util.c')
-rw-r--r--security/tomoyo/util.c363
1 files changed, 209 insertions, 154 deletions
diff --git a/security/tomoyo/util.c b/security/tomoyo/util.c
index 6d5393204d95..c36bd1107fc8 100644
--- a/security/tomoyo/util.c
+++ b/security/tomoyo/util.c
@@ -1,9 +1,7 @@
1/* 1/*
2 * security/tomoyo/util.c 2 * security/tomoyo/util.c
3 * 3 *
4 * Utility functions for TOMOYO. 4 * Copyright (C) 2005-2011 NTT DATA CORPORATION
5 *
6 * Copyright (C) 2005-2010 NTT DATA CORPORATION
7 */ 5 */
8 6
9#include <linux/slab.h> 7#include <linux/slab.h>
@@ -15,18 +13,130 @@ DEFINE_MUTEX(tomoyo_policy_lock);
15/* Has /sbin/init started? */ 13/* Has /sbin/init started? */
16bool tomoyo_policy_loaded; 14bool tomoyo_policy_loaded;
17 15
16/*
17 * Mapping table from "enum tomoyo_mac_index" to
18 * "enum tomoyo_mac_category_index".
19 */
20const u8 tomoyo_index2category[TOMOYO_MAX_MAC_INDEX] = {
21 /* CONFIG::file group */
22 [TOMOYO_MAC_FILE_EXECUTE] = TOMOYO_MAC_CATEGORY_FILE,
23 [TOMOYO_MAC_FILE_OPEN] = TOMOYO_MAC_CATEGORY_FILE,
24 [TOMOYO_MAC_FILE_CREATE] = TOMOYO_MAC_CATEGORY_FILE,
25 [TOMOYO_MAC_FILE_UNLINK] = TOMOYO_MAC_CATEGORY_FILE,
26 [TOMOYO_MAC_FILE_GETATTR] = TOMOYO_MAC_CATEGORY_FILE,
27 [TOMOYO_MAC_FILE_MKDIR] = TOMOYO_MAC_CATEGORY_FILE,
28 [TOMOYO_MAC_FILE_RMDIR] = TOMOYO_MAC_CATEGORY_FILE,
29 [TOMOYO_MAC_FILE_MKFIFO] = TOMOYO_MAC_CATEGORY_FILE,
30 [TOMOYO_MAC_FILE_MKSOCK] = TOMOYO_MAC_CATEGORY_FILE,
31 [TOMOYO_MAC_FILE_TRUNCATE] = TOMOYO_MAC_CATEGORY_FILE,
32 [TOMOYO_MAC_FILE_SYMLINK] = TOMOYO_MAC_CATEGORY_FILE,
33 [TOMOYO_MAC_FILE_MKBLOCK] = TOMOYO_MAC_CATEGORY_FILE,
34 [TOMOYO_MAC_FILE_MKCHAR] = TOMOYO_MAC_CATEGORY_FILE,
35 [TOMOYO_MAC_FILE_LINK] = TOMOYO_MAC_CATEGORY_FILE,
36 [TOMOYO_MAC_FILE_RENAME] = TOMOYO_MAC_CATEGORY_FILE,
37 [TOMOYO_MAC_FILE_CHMOD] = TOMOYO_MAC_CATEGORY_FILE,
38 [TOMOYO_MAC_FILE_CHOWN] = TOMOYO_MAC_CATEGORY_FILE,
39 [TOMOYO_MAC_FILE_CHGRP] = TOMOYO_MAC_CATEGORY_FILE,
40 [TOMOYO_MAC_FILE_IOCTL] = TOMOYO_MAC_CATEGORY_FILE,
41 [TOMOYO_MAC_FILE_CHROOT] = TOMOYO_MAC_CATEGORY_FILE,
42 [TOMOYO_MAC_FILE_MOUNT] = TOMOYO_MAC_CATEGORY_FILE,
43 [TOMOYO_MAC_FILE_UMOUNT] = TOMOYO_MAC_CATEGORY_FILE,
44 [TOMOYO_MAC_FILE_PIVOT_ROOT] = TOMOYO_MAC_CATEGORY_FILE,
45};
46
47/**
48 * tomoyo_convert_time - Convert time_t to YYYY/MM/DD hh/mm/ss.
49 *
50 * @time: Seconds since 1970/01/01 00:00:00.
51 * @stamp: Pointer to "struct tomoyo_time".
52 *
53 * Returns nothing.
54 *
55 * This function does not handle Y2038 problem.
56 */
57void tomoyo_convert_time(time_t time, struct tomoyo_time *stamp)
58{
59 static const u16 tomoyo_eom[2][12] = {
60 { 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
61 { 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
62 };
63 u16 y;
64 u8 m;
65 bool r;
66 stamp->sec = time % 60;
67 time /= 60;
68 stamp->min = time % 60;
69 time /= 60;
70 stamp->hour = time % 24;
71 time /= 24;
72 for (y = 1970; ; y++) {
73 const unsigned short days = (y & 3) ? 365 : 366;
74 if (time < days)
75 break;
76 time -= days;
77 }
78 r = (y & 3) == 0;
79 for (m = 0; m < 11 && time >= tomoyo_eom[r][m]; m++)
80 ;
81 if (m)
82 time -= tomoyo_eom[r][m - 1];
83 stamp->year = y;
84 stamp->month = ++m;
85 stamp->day = ++time;
86}
87
88/**
89 * tomoyo_permstr - Find permission keywords.
90 *
91 * @string: String representation for permissions in foo/bar/buz format.
92 * @keyword: Keyword to find from @string/
93 *
94 * Returns ture if @keyword was found in @string, false otherwise.
95 *
96 * This function assumes that strncmp(w1, w2, strlen(w1)) != 0 if w1 != w2.
97 */
98bool tomoyo_permstr(const char *string, const char *keyword)
99{
100 const char *cp = strstr(string, keyword);
101 if (cp)
102 return cp == string || *(cp - 1) == '/';
103 return false;
104}
105
106/**
107 * tomoyo_read_token - Read a word from a line.
108 *
109 * @param: Pointer to "struct tomoyo_acl_param".
110 *
111 * Returns a word on success, "" otherwise.
112 *
113 * To allow the caller to skip NULL check, this function returns "" rather than
114 * NULL if there is no more words to read.
115 */
116char *tomoyo_read_token(struct tomoyo_acl_param *param)
117{
118 char *pos = param->data;
119 char *del = strchr(pos, ' ');
120 if (del)
121 *del++ = '\0';
122 else
123 del = pos + strlen(pos);
124 param->data = del;
125 return pos;
126}
127
18/** 128/**
19 * tomoyo_parse_ulong - Parse an "unsigned long" value. 129 * tomoyo_parse_ulong - Parse an "unsigned long" value.
20 * 130 *
21 * @result: Pointer to "unsigned long". 131 * @result: Pointer to "unsigned long".
22 * @str: Pointer to string to parse. 132 * @str: Pointer to string to parse.
23 * 133 *
24 * Returns value type on success, 0 otherwise. 134 * Returns one of values in "enum tomoyo_value_type".
25 * 135 *
26 * The @src is updated to point the first character after the value 136 * The @src is updated to point the first character after the value
27 * on success. 137 * on success.
28 */ 138 */
29static u8 tomoyo_parse_ulong(unsigned long *result, char **str) 139u8 tomoyo_parse_ulong(unsigned long *result, char **str)
30{ 140{
31 const char *cp = *str; 141 const char *cp = *str;
32 char *ep; 142 char *ep;
@@ -43,7 +153,7 @@ static u8 tomoyo_parse_ulong(unsigned long *result, char **str)
43 } 153 }
44 *result = simple_strtoul(cp, &ep, base); 154 *result = simple_strtoul(cp, &ep, base);
45 if (cp == ep) 155 if (cp == ep)
46 return 0; 156 return TOMOYO_VALUE_TYPE_INVALID;
47 *str = ep; 157 *str = ep;
48 switch (base) { 158 switch (base) {
49 case 16: 159 case 16:
@@ -81,63 +191,65 @@ void tomoyo_print_ulong(char *buffer, const int buffer_len,
81/** 191/**
82 * tomoyo_parse_name_union - Parse a tomoyo_name_union. 192 * tomoyo_parse_name_union - Parse a tomoyo_name_union.
83 * 193 *
84 * @filename: Name or name group. 194 * @param: Pointer to "struct tomoyo_acl_param".
85 * @ptr: Pointer to "struct tomoyo_name_union". 195 * @ptr: Pointer to "struct tomoyo_name_union".
86 * 196 *
87 * Returns true on success, false otherwise. 197 * Returns true on success, false otherwise.
88 */ 198 */
89bool tomoyo_parse_name_union(const char *filename, 199bool tomoyo_parse_name_union(struct tomoyo_acl_param *param,
90 struct tomoyo_name_union *ptr) 200 struct tomoyo_name_union *ptr)
91{ 201{
92 if (!tomoyo_correct_word(filename)) 202 char *filename;
93 return false; 203 if (param->data[0] == '@') {
94 if (filename[0] == '@') { 204 param->data++;
95 ptr->group = tomoyo_get_group(filename + 1, TOMOYO_PATH_GROUP); 205 ptr->group = tomoyo_get_group(param, TOMOYO_PATH_GROUP);
96 ptr->is_group = true;
97 return ptr->group != NULL; 206 return ptr->group != NULL;
98 } 207 }
208 filename = tomoyo_read_token(param);
209 if (!tomoyo_correct_word(filename))
210 return false;
99 ptr->filename = tomoyo_get_name(filename); 211 ptr->filename = tomoyo_get_name(filename);
100 ptr->is_group = false;
101 return ptr->filename != NULL; 212 return ptr->filename != NULL;
102} 213}
103 214
104/** 215/**
105 * tomoyo_parse_number_union - Parse a tomoyo_number_union. 216 * tomoyo_parse_number_union - Parse a tomoyo_number_union.
106 * 217 *
107 * @data: Number or number range or number group. 218 * @param: Pointer to "struct tomoyo_acl_param".
108 * @ptr: Pointer to "struct tomoyo_number_union". 219 * @ptr: Pointer to "struct tomoyo_number_union".
109 * 220 *
110 * Returns true on success, false otherwise. 221 * Returns true on success, false otherwise.
111 */ 222 */
112bool tomoyo_parse_number_union(char *data, struct tomoyo_number_union *num) 223bool tomoyo_parse_number_union(struct tomoyo_acl_param *param,
224 struct tomoyo_number_union *ptr)
113{ 225{
226 char *data;
114 u8 type; 227 u8 type;
115 unsigned long v; 228 unsigned long v;
116 memset(num, 0, sizeof(*num)); 229 memset(ptr, 0, sizeof(*ptr));
117 if (data[0] == '@') { 230 if (param->data[0] == '@') {
118 if (!tomoyo_correct_word(data)) 231 param->data++;
119 return false; 232 ptr->group = tomoyo_get_group(param, TOMOYO_NUMBER_GROUP);
120 num->group = tomoyo_get_group(data + 1, TOMOYO_NUMBER_GROUP); 233 return ptr->group != NULL;
121 num->is_group = true;
122 return num->group != NULL;
123 } 234 }
235 data = tomoyo_read_token(param);
124 type = tomoyo_parse_ulong(&v, &data); 236 type = tomoyo_parse_ulong(&v, &data);
125 if (!type) 237 if (type == TOMOYO_VALUE_TYPE_INVALID)
126 return false; 238 return false;
127 num->values[0] = v; 239 ptr->values[0] = v;
128 num->min_type = type; 240 ptr->value_type[0] = type;
129 if (!*data) { 241 if (!*data) {
130 num->values[1] = v; 242 ptr->values[1] = v;
131 num->max_type = type; 243 ptr->value_type[1] = type;
132 return true; 244 return true;
133 } 245 }
134 if (*data++ != '-') 246 if (*data++ != '-')
135 return false; 247 return false;
136 type = tomoyo_parse_ulong(&v, &data); 248 type = tomoyo_parse_ulong(&v, &data);
137 if (!type || *data) 249 if (type == TOMOYO_VALUE_TYPE_INVALID || *data || ptr->values[0] > v)
138 return false; 250 return false;
139 num->values[1] = v; 251 ptr->values[1] = v;
140 num->max_type = type; 252 ptr->value_type[1] = type;
141 return true; 253 return true;
142} 254}
143 255
@@ -185,6 +297,30 @@ static inline u8 tomoyo_make_byte(const u8 c1, const u8 c2, const u8 c3)
185} 297}
186 298
187/** 299/**
300 * tomoyo_valid - Check whether the character is a valid char.
301 *
302 * @c: The character to check.
303 *
304 * Returns true if @c is a valid character, false otherwise.
305 */
306static inline bool tomoyo_valid(const unsigned char c)
307{
308 return c > ' ' && c < 127;
309}
310
311/**
312 * tomoyo_invalid - Check whether the character is an invalid char.
313 *
314 * @c: The character to check.
315 *
316 * Returns true if @c is an invalid character, false otherwise.
317 */
318static inline bool tomoyo_invalid(const unsigned char c)
319{
320 return c && (c <= ' ' || c >= 127);
321}
322
323/**
188 * tomoyo_str_starts - Check whether the given string starts with the given keyword. 324 * tomoyo_str_starts - Check whether the given string starts with the given keyword.
189 * 325 *
190 * @src: Pointer to pointer to the string. 326 * @src: Pointer to pointer to the string.
@@ -238,36 +374,9 @@ void tomoyo_normalize_line(unsigned char *buffer)
238} 374}
239 375
240/** 376/**
241 * tomoyo_tokenize - Tokenize string.
242 *
243 * @buffer: The line to tokenize.
244 * @w: Pointer to "char *".
245 * @size: Sizeof @w .
246 *
247 * Returns true on success, false otherwise.
248 */
249bool tomoyo_tokenize(char *buffer, char *w[], size_t size)
250{
251 int count = size / sizeof(char *);
252 int i;
253 for (i = 0; i < count; i++)
254 w[i] = "";
255 for (i = 0; i < count; i++) {
256 char *cp = strchr(buffer, ' ');
257 if (cp)
258 *cp = '\0';
259 w[i] = buffer;
260 if (!cp)
261 break;
262 buffer = cp + 1;
263 }
264 return i < count || !*buffer;
265}
266
267/**
268 * tomoyo_correct_word2 - Validate a string. 377 * tomoyo_correct_word2 - Validate a string.
269 * 378 *
270 * @string: The string to check. May be non-'\0'-terminated. 379 * @string: The string to check. Maybe non-'\0'-terminated.
271 * @len: Length of @string. 380 * @len: Length of @string.
272 * 381 *
273 * Check whether the given string follows the naming rules. 382 * Check whether the given string follows the naming rules.
@@ -377,26 +486,21 @@ bool tomoyo_correct_path(const char *filename)
377 */ 486 */
378bool tomoyo_correct_domain(const unsigned char *domainname) 487bool tomoyo_correct_domain(const unsigned char *domainname)
379{ 488{
380 if (!domainname || strncmp(domainname, TOMOYO_ROOT_NAME, 489 if (!domainname || !tomoyo_domain_def(domainname))
381 TOMOYO_ROOT_NAME_LEN)) 490 return false;
382 goto out; 491 domainname = strchr(domainname, ' ');
383 domainname += TOMOYO_ROOT_NAME_LEN; 492 if (!domainname++)
384 if (!*domainname)
385 return true; 493 return true;
386 if (*domainname++ != ' ')
387 goto out;
388 while (1) { 494 while (1) {
389 const unsigned char *cp = strchr(domainname, ' '); 495 const unsigned char *cp = strchr(domainname, ' ');
390 if (!cp) 496 if (!cp)
391 break; 497 break;
392 if (*domainname != '/' || 498 if (*domainname != '/' ||
393 !tomoyo_correct_word2(domainname, cp - domainname)) 499 !tomoyo_correct_word2(domainname, cp - domainname))
394 goto out; 500 return false;
395 domainname = cp + 1; 501 domainname = cp + 1;
396 } 502 }
397 return tomoyo_correct_path(domainname); 503 return tomoyo_correct_path(domainname);
398 out:
399 return false;
400} 504}
401 505
402/** 506/**
@@ -408,7 +512,19 @@ bool tomoyo_correct_domain(const unsigned char *domainname)
408 */ 512 */
409bool tomoyo_domain_def(const unsigned char *buffer) 513bool tomoyo_domain_def(const unsigned char *buffer)
410{ 514{
411 return !strncmp(buffer, TOMOYO_ROOT_NAME, TOMOYO_ROOT_NAME_LEN); 515 const unsigned char *cp;
516 int len;
517 if (*buffer != '<')
518 return false;
519 cp = strchr(buffer, ' ');
520 if (!cp)
521 len = strlen(buffer);
522 else
523 len = cp - buffer;
524 if (buffer[len - 1] != '>' ||
525 !tomoyo_correct_word2(buffer + 1, len - 2))
526 return false;
527 return true;
412} 528}
413 529
414/** 530/**
@@ -794,22 +910,24 @@ const char *tomoyo_get_exe(void)
794/** 910/**
795 * tomoyo_get_mode - Get MAC mode. 911 * tomoyo_get_mode - Get MAC mode.
796 * 912 *
913 * @ns: Pointer to "struct tomoyo_policy_namespace".
797 * @profile: Profile number. 914 * @profile: Profile number.
798 * @index: Index number of functionality. 915 * @index: Index number of functionality.
799 * 916 *
800 * Returns mode. 917 * Returns mode.
801 */ 918 */
802int tomoyo_get_mode(const u8 profile, const u8 index) 919int tomoyo_get_mode(const struct tomoyo_policy_namespace *ns, const u8 profile,
920 const u8 index)
803{ 921{
804 u8 mode; 922 u8 mode;
805 const u8 category = TOMOYO_MAC_CATEGORY_FILE; 923 const u8 category = TOMOYO_MAC_CATEGORY_FILE;
806 if (!tomoyo_policy_loaded) 924 if (!tomoyo_policy_loaded)
807 return TOMOYO_CONFIG_DISABLED; 925 return TOMOYO_CONFIG_DISABLED;
808 mode = tomoyo_profile(profile)->config[index]; 926 mode = tomoyo_profile(ns, profile)->config[index];
809 if (mode == TOMOYO_CONFIG_USE_DEFAULT) 927 if (mode == TOMOYO_CONFIG_USE_DEFAULT)
810 mode = tomoyo_profile(profile)->config[category]; 928 mode = tomoyo_profile(ns, profile)->config[category];
811 if (mode == TOMOYO_CONFIG_USE_DEFAULT) 929 if (mode == TOMOYO_CONFIG_USE_DEFAULT)
812 mode = tomoyo_profile(profile)->default_config; 930 mode = tomoyo_profile(ns, profile)->default_config;
813 return mode & 3; 931 return mode & 3;
814} 932}
815 933
@@ -833,65 +951,11 @@ int tomoyo_init_request_info(struct tomoyo_request_info *r,
833 profile = domain->profile; 951 profile = domain->profile;
834 r->profile = profile; 952 r->profile = profile;
835 r->type = index; 953 r->type = index;
836 r->mode = tomoyo_get_mode(profile, index); 954 r->mode = tomoyo_get_mode(domain->ns, profile, index);
837 return r->mode; 955 return r->mode;
838} 956}
839 957
840/** 958/**
841 * tomoyo_last_word - Get last component of a line.
842 *
843 * @line: A line.
844 *
845 * Returns the last word of a line.
846 */
847const char *tomoyo_last_word(const char *name)
848{
849 const char *cp = strrchr(name, ' ');
850 if (cp)
851 return cp + 1;
852 return name;
853}
854
855/**
856 * tomoyo_warn_log - Print warning or error message on console.
857 *
858 * @r: Pointer to "struct tomoyo_request_info".
859 * @fmt: The printf()'s format string, followed by parameters.
860 */
861void tomoyo_warn_log(struct tomoyo_request_info *r, const char *fmt, ...)
862{
863 va_list args;
864 char *buffer;
865 const struct tomoyo_domain_info * const domain = r->domain;
866 const struct tomoyo_profile *profile = tomoyo_profile(domain->profile);
867 switch (r->mode) {
868 case TOMOYO_CONFIG_ENFORCING:
869 if (!profile->enforcing->enforcing_verbose)
870 return;
871 break;
872 case TOMOYO_CONFIG_PERMISSIVE:
873 if (!profile->permissive->permissive_verbose)
874 return;
875 break;
876 case TOMOYO_CONFIG_LEARNING:
877 if (!profile->learning->learning_verbose)
878 return;
879 break;
880 }
881 buffer = kmalloc(4096, GFP_NOFS);
882 if (!buffer)
883 return;
884 va_start(args, fmt);
885 vsnprintf(buffer, 4095, fmt, args);
886 va_end(args);
887 buffer[4095] = '\0';
888 printk(KERN_WARNING "%s: Access %s denied for %s\n",
889 r->mode == TOMOYO_CONFIG_ENFORCING ? "ERROR" : "WARNING", buffer,
890 tomoyo_last_word(domain->domainname->name));
891 kfree(buffer);
892}
893
894/**
895 * tomoyo_domain_quota_is_ok - Check for domain's quota. 959 * tomoyo_domain_quota_is_ok - Check for domain's quota.
896 * 960 *
897 * @r: Pointer to "struct tomoyo_request_info". 961 * @r: Pointer to "struct tomoyo_request_info".
@@ -911,52 +975,43 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)
911 if (!domain) 975 if (!domain)
912 return true; 976 return true;
913 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 977 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
978 u16 perm;
979 u8 i;
914 if (ptr->is_deleted) 980 if (ptr->is_deleted)
915 continue; 981 continue;
916 switch (ptr->type) { 982 switch (ptr->type) {
917 u16 perm;
918 u8 i;
919 case TOMOYO_TYPE_PATH_ACL: 983 case TOMOYO_TYPE_PATH_ACL:
920 perm = container_of(ptr, struct tomoyo_path_acl, head) 984 perm = container_of(ptr, struct tomoyo_path_acl, head)
921 ->perm; 985 ->perm;
922 for (i = 0; i < TOMOYO_MAX_PATH_OPERATION; i++)
923 if (perm & (1 << i))
924 count++;
925 if (perm & (1 << TOMOYO_TYPE_READ_WRITE))
926 count -= 2;
927 break; 986 break;
928 case TOMOYO_TYPE_PATH2_ACL: 987 case TOMOYO_TYPE_PATH2_ACL:
929 perm = container_of(ptr, struct tomoyo_path2_acl, head) 988 perm = container_of(ptr, struct tomoyo_path2_acl, head)
930 ->perm; 989 ->perm;
931 for (i = 0; i < TOMOYO_MAX_PATH2_OPERATION; i++)
932 if (perm & (1 << i))
933 count++;
934 break; 990 break;
935 case TOMOYO_TYPE_PATH_NUMBER_ACL: 991 case TOMOYO_TYPE_PATH_NUMBER_ACL:
936 perm = container_of(ptr, struct tomoyo_path_number_acl, 992 perm = container_of(ptr, struct tomoyo_path_number_acl,
937 head)->perm; 993 head)->perm;
938 for (i = 0; i < TOMOYO_MAX_PATH_NUMBER_OPERATION; i++)
939 if (perm & (1 << i))
940 count++;
941 break; 994 break;
942 case TOMOYO_TYPE_MKDEV_ACL: 995 case TOMOYO_TYPE_MKDEV_ACL:
943 perm = container_of(ptr, struct tomoyo_mkdev_acl, 996 perm = container_of(ptr, struct tomoyo_mkdev_acl,
944 head)->perm; 997 head)->perm;
945 for (i = 0; i < TOMOYO_MAX_MKDEV_OPERATION; i++)
946 if (perm & (1 << i))
947 count++;
948 break; 998 break;
949 default: 999 default:
950 count++; 1000 perm = 1;
951 } 1001 }
1002 for (i = 0; i < 16; i++)
1003 if (perm & (1 << i))
1004 count++;
952 } 1005 }
953 if (count < tomoyo_profile(domain->profile)->learning-> 1006 if (count < tomoyo_profile(domain->ns, domain->profile)->
954 learning_max_entry) 1007 pref[TOMOYO_PREF_MAX_LEARNING_ENTRY])
955 return true; 1008 return true;
956 if (!domain->quota_warned) { 1009 if (!domain->flags[TOMOYO_DIF_QUOTA_WARNED]) {
957 domain->quota_warned = true; 1010 domain->flags[TOMOYO_DIF_QUOTA_WARNED] = true;
958 printk(KERN_WARNING "TOMOYO-WARNING: " 1011 /* r->granted = false; */
959 "Domain '%s' has so many ACLs to hold. " 1012 tomoyo_write_log(r, "%s", tomoyo_dif[TOMOYO_DIF_QUOTA_WARNED]);
1013 printk(KERN_WARNING "WARNING: "
1014 "Domain '%s' has too many ACLs to hold. "
960 "Stopped learning mode.\n", domain->domainname->name); 1015 "Stopped learning mode.\n", domain->domainname->name);
961 } 1016 }
962 return false; 1017 return false;