2 * security/tomoyo/common.h
4 * Header file for TOMOYO.
6 * Copyright (C) 2005-2010 NTT DATA CORPORATION
9 #ifndef _SECURITY_TOMOYO_COMMON_H
10 #define _SECURITY_TOMOYO_COMMON_H
12 #include <linux/ctype.h>
13 #include <linux/string.h>
15 #include <linux/file.h>
16 #include <linux/kmod.h>
18 #include <linux/sched.h>
19 #include <linux/namei.h>
20 #include <linux/mount.h>
21 #include <linux/list.h>
22 #include <linux/cred.h>
23 #include <linux/poll.h>
26 /********** Constants definitions. **********/
29 * TOMOYO uses this hash only when appending a string into the string
30 * table. Frequency of appending strings is very low. So we don't need
31 * large (e.g. 64k) hash size. 256 will be sufficient.
33 #define TOMOYO_HASH_BITS 8
34 #define TOMOYO_MAX_HASH (1u<<TOMOYO_HASH_BITS)
36 #define TOMOYO_EXEC_TMPSIZE 4096
38 /* Profile number is an integer between 0 and 255. */
39 #define TOMOYO_MAX_PROFILES 256
41 /* Index numbers for operation mode. */
42 enum tomoyo_mode_index {
43 TOMOYO_CONFIG_DISABLED,
44 TOMOYO_CONFIG_LEARNING,
45 TOMOYO_CONFIG_PERMISSIVE,
46 TOMOYO_CONFIG_ENFORCING,
47 TOMOYO_CONFIG_USE_DEFAULT = 255
50 /* Index numbers for entry type. */
51 enum tomoyo_policy_id {
54 TOMOYO_ID_NUMBER_GROUP,
55 TOMOYO_ID_TRANSITION_CONTROL,
64 /* Index numbers for group entries. */
65 enum tomoyo_group_id {
71 /* A domain definition starts with <kernel>. */
72 #define TOMOYO_ROOT_NAME "<kernel>"
73 #define TOMOYO_ROOT_NAME_LEN (sizeof(TOMOYO_ROOT_NAME) - 1)
75 /* Index numbers for type of numeric values. */
76 enum tomoyo_value_type {
77 TOMOYO_VALUE_TYPE_INVALID,
78 TOMOYO_VALUE_TYPE_DECIMAL,
79 TOMOYO_VALUE_TYPE_OCTAL,
80 TOMOYO_VALUE_TYPE_HEXADECIMAL,
83 /* Index numbers for domain transition control keywords. */
84 enum tomoyo_transition_type {
85 /* Do not change this order, */
86 TOMOYO_TRANSITION_CONTROL_NO_INITIALIZE,
87 TOMOYO_TRANSITION_CONTROL_INITIALIZE,
88 TOMOYO_TRANSITION_CONTROL_NO_KEEP,
89 TOMOYO_TRANSITION_CONTROL_KEEP,
90 TOMOYO_MAX_TRANSITION_TYPE
93 /* Index numbers for Access Controls. */
94 enum tomoyo_acl_entry_type_index {
96 TOMOYO_TYPE_PATH2_ACL,
97 TOMOYO_TYPE_PATH_NUMBER_ACL,
98 TOMOYO_TYPE_MKDEV_ACL,
99 TOMOYO_TYPE_MOUNT_ACL,
102 /* Index numbers for access controls with one pathname. */
103 enum tomoyo_path_acl_index {
111 TOMOYO_TYPE_TRUNCATE,
115 TOMOYO_MAX_PATH_OPERATION
118 enum tomoyo_mkdev_acl_index {
121 TOMOYO_MAX_MKDEV_OPERATION
124 /* Index numbers for access controls with two pathnames. */
125 enum tomoyo_path2_acl_index {
128 TOMOYO_TYPE_PIVOT_ROOT,
129 TOMOYO_MAX_PATH2_OPERATION
132 /* Index numbers for access controls with one pathname and one number. */
133 enum tomoyo_path_number_acl_index {
142 TOMOYO_MAX_PATH_NUMBER_OPERATION
145 /* Index numbers for /sys/kernel/security/tomoyo/ interfaces. */
146 enum tomoyo_securityfs_interface_index {
148 TOMOYO_EXCEPTIONPOLICY,
149 TOMOYO_DOMAIN_STATUS,
150 TOMOYO_PROCESS_STATUS,
159 /* Index numbers for special mount operations. */
160 enum tomoyo_special_mount {
161 TOMOYO_MOUNT_BIND, /* mount --bind /source /dest */
162 TOMOYO_MOUNT_MOVE, /* mount --move /old /new */
163 TOMOYO_MOUNT_REMOUNT, /* mount -o remount /dir */
164 TOMOYO_MOUNT_MAKE_UNBINDABLE, /* mount --make-unbindable /dir */
165 TOMOYO_MOUNT_MAKE_PRIVATE, /* mount --make-private /dir */
166 TOMOYO_MOUNT_MAKE_SLAVE, /* mount --make-slave /dir */
167 TOMOYO_MOUNT_MAKE_SHARED, /* mount --make-shared /dir */
168 TOMOYO_MAX_SPECIAL_MOUNT
171 /* Index numbers for functionality. */
172 enum tomoyo_mac_index {
173 TOMOYO_MAC_FILE_EXECUTE,
174 TOMOYO_MAC_FILE_OPEN,
175 TOMOYO_MAC_FILE_CREATE,
176 TOMOYO_MAC_FILE_UNLINK,
177 TOMOYO_MAC_FILE_GETATTR,
178 TOMOYO_MAC_FILE_MKDIR,
179 TOMOYO_MAC_FILE_RMDIR,
180 TOMOYO_MAC_FILE_MKFIFO,
181 TOMOYO_MAC_FILE_MKSOCK,
182 TOMOYO_MAC_FILE_TRUNCATE,
183 TOMOYO_MAC_FILE_SYMLINK,
184 TOMOYO_MAC_FILE_MKBLOCK,
185 TOMOYO_MAC_FILE_MKCHAR,
186 TOMOYO_MAC_FILE_LINK,
187 TOMOYO_MAC_FILE_RENAME,
188 TOMOYO_MAC_FILE_CHMOD,
189 TOMOYO_MAC_FILE_CHOWN,
190 TOMOYO_MAC_FILE_CHGRP,
191 TOMOYO_MAC_FILE_IOCTL,
192 TOMOYO_MAC_FILE_CHROOT,
193 TOMOYO_MAC_FILE_MOUNT,
194 TOMOYO_MAC_FILE_UMOUNT,
195 TOMOYO_MAC_FILE_PIVOT_ROOT,
199 /* Index numbers for category of functionality. */
200 enum tomoyo_mac_category_index {
201 TOMOYO_MAC_CATEGORY_FILE,
202 TOMOYO_MAX_MAC_CATEGORY_INDEX
206 * Retry this request. Returned by tomoyo_supervisor() if policy violation has
207 * occurred in enforcing mode and the userspace daemon decided to retry.
209 * We must choose a positive value in order to distinguish "granted" (which is
210 * 0) and "rejected" (which is a negative value) and "retry".
212 #define TOMOYO_RETRY_REQUEST 1
214 /********** Structure definitions. **********/
216 /* Common header for holding ACL entries. */
217 struct tomoyo_acl_head {
218 struct list_head list;
222 /* Structure for request info. */
223 struct tomoyo_request_info {
224 struct tomoyo_domain_info *domain;
225 /* For holding parameters. */
228 const struct tomoyo_path_info *filename;
229 /* For using wildcards at tomoyo_find_next_domain(). */
230 const struct tomoyo_path_info *matched_path;
231 /* One of values in "enum tomoyo_path_acl_index". */
235 const struct tomoyo_path_info *filename1;
236 const struct tomoyo_path_info *filename2;
237 /* One of values in "enum tomoyo_path2_acl_index". */
241 const struct tomoyo_path_info *filename;
245 /* One of values in "enum tomoyo_mkdev_acl_index". */
249 const struct tomoyo_path_info *filename;
250 unsigned long number;
253 * "enum tomoyo_path_number_acl_index".
258 const struct tomoyo_path_info *type;
259 const struct tomoyo_path_info *dir;
260 const struct tomoyo_path_info *dev;
269 u8 mode; /* One of tomoyo_mode_index . */
273 /* Structure for holding a token. */
274 struct tomoyo_path_info {
276 u32 hash; /* = full_name_hash(name, strlen(name)) */
277 u16 const_len; /* = tomoyo_const_part_length(name) */
278 bool is_dir; /* = tomoyo_strendswith(name, "/") */
279 bool is_patterned; /* = tomoyo_path_contains_pattern(name) */
282 /* Structure for holding string data. */
284 struct list_head list;
286 struct tomoyo_path_info entry;
289 /* Structure for holding a word. */
290 struct tomoyo_name_union {
291 /* Either @filename or @group is NULL. */
292 const struct tomoyo_path_info *filename;
293 struct tomoyo_group *group;
294 /* True if @group != NULL, false if @filename != NULL. */
298 /* Structure for holding a number. */
299 struct tomoyo_number_union {
300 unsigned long values[2];
301 struct tomoyo_group *group; /* Maybe NULL. */
302 /* One of values in "enum tomoyo_value_type". */
305 /* True if @group != NULL, false otherwise. */
309 /* Structure for "path_group"/"number_group" directive. */
310 struct tomoyo_group {
311 struct list_head list;
312 const struct tomoyo_path_info *group_name;
313 struct list_head member_list;
317 /* Structure for "path_group" directive. */
318 struct tomoyo_path_group {
319 struct tomoyo_acl_head head;
320 const struct tomoyo_path_info *member_name;
323 /* Structure for "number_group" directive. */
324 struct tomoyo_number_group {
325 struct tomoyo_acl_head head;
326 struct tomoyo_number_union number;
329 /* Common header for individual entries. */
330 struct tomoyo_acl_info {
331 struct list_head list;
333 u8 type; /* One of values in "enum tomoyo_acl_entry_type_index". */
336 /* Structure for domain information. */
337 struct tomoyo_domain_info {
338 struct list_head list;
339 struct list_head acl_info_list;
340 /* Name of this domain. Never NULL. */
341 const struct tomoyo_path_info *domainname;
342 u8 profile; /* Profile number to use. */
343 bool is_deleted; /* Delete flag. */
344 bool quota_warned; /* Quota warnning flag. */
345 bool transition_failed; /* Domain transition failed flag. */
346 atomic_t users; /* Number of referring credentials. */
350 * Structure for "file execute", "file read", "file write", "file append",
351 * "file unlink", "file getattr", "file rmdir", "file truncate",
352 * "file symlink", "file chroot" and "file unmount" directive.
354 struct tomoyo_path_acl {
355 struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH_ACL */
356 u16 perm; /* Bitmask of values in "enum tomoyo_path_acl_index". */
357 struct tomoyo_name_union name;
361 * Structure for "file create", "file mkdir", "file mkfifo", "file mksock",
362 * "file ioctl", "file chmod", "file chown" and "file chgrp" directive.
364 struct tomoyo_path_number_acl {
365 struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH_NUMBER_ACL */
366 /* Bitmask of values in "enum tomoyo_path_number_acl_index". */
368 struct tomoyo_name_union name;
369 struct tomoyo_number_union number;
372 /* Structure for "file mkblock" and "file mkchar" directive. */
373 struct tomoyo_mkdev_acl {
374 struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_MKDEV_ACL */
375 u8 perm; /* Bitmask of values in "enum tomoyo_mkdev_acl_index". */
376 struct tomoyo_name_union name;
377 struct tomoyo_number_union mode;
378 struct tomoyo_number_union major;
379 struct tomoyo_number_union minor;
383 * Structure for "file rename", "file link" and "file pivot_root" directive.
385 struct tomoyo_path2_acl {
386 struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH2_ACL */
387 u8 perm; /* Bitmask of values in "enum tomoyo_path2_acl_index". */
388 struct tomoyo_name_union name1;
389 struct tomoyo_name_union name2;
392 /* Structure for "file mount" directive. */
393 struct tomoyo_mount_acl {
394 struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_MOUNT_ACL */
395 struct tomoyo_name_union dev_name;
396 struct tomoyo_name_union dir_name;
397 struct tomoyo_name_union fs_type;
398 struct tomoyo_number_union flags;
401 #define TOMOYO_MAX_IO_READ_QUEUE 32
404 * Structure for reading/writing policy via /sys/kernel/security/tomoyo
407 struct tomoyo_io_buffer {
408 void (*read) (struct tomoyo_io_buffer *);
409 int (*write) (struct tomoyo_io_buffer *);
410 int (*poll) (struct file *file, poll_table *wait);
411 /* Exclusive lock for this structure. */
413 /* Index returned by tomoyo_read_lock(). */
415 char __user *read_user_buf;
416 int read_user_buf_avail;
418 struct list_head *domain;
419 struct list_head *group;
420 struct list_head *acl;
428 bool print_this_domain_only;
429 bool print_execute_only;
430 const char *w[TOMOYO_MAX_IO_READ_QUEUE];
432 /* The position currently writing to. */
433 struct tomoyo_domain_info *write_var1;
434 /* Buffer for reading. */
436 /* Size of read buffer. */
438 /* Buffer for writing. */
440 /* Bytes available for writing. */
442 /* Size of write buffer. */
444 /* Type of this interface. */
449 * Structure for "initialize_domain"/"no_initialize_domain"/"keep_domain"/
450 * "no_keep_domain" keyword.
452 struct tomoyo_transition_control {
453 struct tomoyo_acl_head head;
454 u8 type; /* One of values in "enum tomoyo_transition_type". */
455 /* True if the domainname is tomoyo_get_last_name(). */
457 const struct tomoyo_path_info *domainname; /* Maybe NULL */
458 const struct tomoyo_path_info *program; /* Maybe NULL */
461 /* Structure for "aggregator" keyword. */
462 struct tomoyo_aggregator {
463 struct tomoyo_acl_head head;
464 const struct tomoyo_path_info *original_name;
465 const struct tomoyo_path_info *aggregated_name;
468 /* Structure for policy manager. */
469 struct tomoyo_manager {
470 struct tomoyo_acl_head head;
471 bool is_domain; /* True if manager is a domainname. */
472 /* A path to program or a domainname. */
473 const struct tomoyo_path_info *manager;
476 struct tomoyo_preference {
477 unsigned int learning_max_entry;
478 bool enforcing_verbose;
479 bool learning_verbose;
480 bool permissive_verbose;
483 /* Structure for /sys/kernel/security/tomnoyo/profile interface. */
484 struct tomoyo_profile {
485 const struct tomoyo_path_info *comment;
486 struct tomoyo_preference *learning;
487 struct tomoyo_preference *permissive;
488 struct tomoyo_preference *enforcing;
489 struct tomoyo_preference preference;
491 u8 config[TOMOYO_MAX_MAC_INDEX + TOMOYO_MAX_MAC_CATEGORY_INDEX];
494 /********** Function prototypes. **********/
496 bool tomoyo_str_starts(char **src, const char *find);
497 const char *tomoyo_get_exe(void);
498 void tomoyo_normalize_line(unsigned char *buffer);
499 void tomoyo_warn_log(struct tomoyo_request_info *r, const char *fmt, ...)
500 __attribute__ ((format(printf, 2, 3)));
501 void tomoyo_check_profile(void);
502 int tomoyo_open_control(const u8 type, struct file *file);
503 int tomoyo_close_control(struct file *file);
504 int tomoyo_poll_control(struct file *file, poll_table *wait);
505 int tomoyo_read_control(struct file *file, char __user *buffer,
506 const int buffer_len);
507 int tomoyo_write_control(struct file *file, const char __user *buffer,
508 const int buffer_len);
509 bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r);
510 void tomoyo_warn_oom(const char *function);
511 const struct tomoyo_path_info *
512 tomoyo_compare_name_union(const struct tomoyo_path_info *name,
513 const struct tomoyo_name_union *ptr);
514 bool tomoyo_compare_number_union(const unsigned long value,
515 const struct tomoyo_number_union *ptr);
516 int tomoyo_get_mode(const u8 profile, const u8 index);
517 void tomoyo_io_printf(struct tomoyo_io_buffer *head, const char *fmt, ...)
518 __attribute__ ((format(printf, 2, 3)));
519 bool tomoyo_correct_domain(const unsigned char *domainname);
520 bool tomoyo_correct_path(const char *filename);
521 bool tomoyo_correct_word(const char *string);
522 bool tomoyo_domain_def(const unsigned char *buffer);
523 bool tomoyo_parse_name_union(const char *filename,
524 struct tomoyo_name_union *ptr);
525 const struct tomoyo_path_info *
526 tomoyo_path_matches_group(const struct tomoyo_path_info *pathname,
527 const struct tomoyo_group *group);
528 bool tomoyo_number_matches_group(const unsigned long min,
529 const unsigned long max,
530 const struct tomoyo_group *group);
531 bool tomoyo_path_matches_pattern(const struct tomoyo_path_info *filename,
532 const struct tomoyo_path_info *pattern);
533 bool tomoyo_parse_number_union(char *data, struct tomoyo_number_union *num);
534 bool tomoyo_tokenize(char *buffer, char *w[], size_t size);
535 bool tomoyo_verbose_mode(const struct tomoyo_domain_info *domain);
536 int tomoyo_init_request_info(struct tomoyo_request_info *r,
537 struct tomoyo_domain_info *domain,
539 int tomoyo_mount_permission(char *dev_name, struct path *path,
540 const char *type, unsigned long flags,
542 int tomoyo_write_aggregator(char *data, const bool is_delete);
543 int tomoyo_write_transition_control(char *data, const bool is_delete,
545 int tomoyo_write_file(char *data, struct tomoyo_domain_info *domain,
546 const bool is_delete);
547 int tomoyo_write_mount(char *data, struct tomoyo_domain_info *domain,
548 const bool is_delete);
549 int tomoyo_write_group(char *data, const bool is_delete, const u8 type);
550 int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
551 __attribute__ ((format(printf, 2, 3)));
552 struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname);
553 struct tomoyo_domain_info *tomoyo_assign_domain(const char *domainname,
555 struct tomoyo_profile *tomoyo_profile(const u8 profile);
556 struct tomoyo_group *tomoyo_get_group(const char *group_name, const u8 type);
557 unsigned int tomoyo_check_flags(const struct tomoyo_domain_info *domain,
559 void tomoyo_fill_path_info(struct tomoyo_path_info *ptr);
560 void tomoyo_load_policy(const char *filename);
561 void tomoyo_put_number_union(struct tomoyo_number_union *ptr);
562 char *tomoyo_encode(const char *str);
563 char *tomoyo_realpath_nofollow(const char *pathname);
564 char *tomoyo_realpath_from_path(struct path *path);
565 bool tomoyo_memory_ok(void *ptr);
566 void *tomoyo_commit_ok(void *data, const unsigned int size);
567 const struct tomoyo_path_info *tomoyo_get_name(const char *name);
568 void tomoyo_read_memory_counter(struct tomoyo_io_buffer *head);
569 int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head);
570 void __init tomoyo_mm_init(void);
571 int tomoyo_path_permission(struct tomoyo_request_info *r, u8 operation,
572 const struct tomoyo_path_info *filename);
573 int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
574 struct path *path, const int flag);
575 int tomoyo_path_number_perm(const u8 operation, struct path *path,
576 unsigned long number);
577 int tomoyo_mkdev_perm(const u8 operation, struct path *path,
578 const unsigned int mode, unsigned int dev);
579 int tomoyo_path_perm(const u8 operation, struct path *path);
580 int tomoyo_path2_perm(const u8 operation, struct path *path1,
582 int tomoyo_find_next_domain(struct linux_binprm *bprm);
583 void tomoyo_print_ulong(char *buffer, const int buffer_len,
584 const unsigned long value, const u8 type);
585 void tomoyo_put_name_union(struct tomoyo_name_union *ptr);
586 void tomoyo_run_gc(void);
587 void tomoyo_memory_free(void *ptr);
588 int tomoyo_update_domain(struct tomoyo_acl_info *new_entry, const int size,
589 bool is_delete, struct tomoyo_domain_info *domain,
590 bool (*check_duplicate) (const struct tomoyo_acl_info
592 const struct tomoyo_acl_info
594 bool (*merge_duplicate) (struct tomoyo_acl_info *,
595 struct tomoyo_acl_info *,
597 int tomoyo_update_policy(struct tomoyo_acl_head *new_entry, const int size,
598 bool is_delete, struct list_head *list,
599 bool (*check_duplicate) (const struct tomoyo_acl_head
601 const struct tomoyo_acl_head
603 void tomoyo_check_acl(struct tomoyo_request_info *r,
604 bool (*check_entry) (struct tomoyo_request_info *,
605 const struct tomoyo_acl_info *));
607 /********** External variable definitions. **********/
610 extern struct srcu_struct tomoyo_ss;
612 /* The list for "struct tomoyo_domain_info". */
613 extern struct list_head tomoyo_domain_list;
615 extern struct list_head tomoyo_policy_list[TOMOYO_MAX_POLICY];
616 extern struct list_head tomoyo_group_list[TOMOYO_MAX_GROUP];
617 extern struct list_head tomoyo_name_list[TOMOYO_MAX_HASH];
619 /* Lock for protecting policy. */
620 extern struct mutex tomoyo_policy_lock;
622 /* Has /sbin/init started? */
623 extern bool tomoyo_policy_loaded;
625 /* The kernel's domain. */
626 extern struct tomoyo_domain_info tomoyo_kernel_domain;
628 extern const char *tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION];
629 extern const char *tomoyo_mkdev_keyword[TOMOYO_MAX_MKDEV_OPERATION];
630 extern const char *tomoyo_path2_keyword[TOMOYO_MAX_PATH2_OPERATION];
631 extern const char *tomoyo_path_number_keyword[TOMOYO_MAX_PATH_NUMBER_OPERATION];
633 extern unsigned int tomoyo_quota_for_query;
634 extern unsigned int tomoyo_query_memory_size;
636 /********** Inlined functions. **********/
639 * tomoyo_read_lock - Take lock for protecting policy.
641 * Returns index number for tomoyo_read_unlock().
643 static inline int tomoyo_read_lock(void)
645 return srcu_read_lock(&tomoyo_ss);
649 * tomoyo_read_unlock - Release lock for protecting policy.
651 * @idx: Index number returned by tomoyo_read_lock().
655 static inline void tomoyo_read_unlock(int idx)
657 srcu_read_unlock(&tomoyo_ss, idx);
661 * tomoyo_pathcmp - strcmp() for "struct tomoyo_path_info" structure.
663 * @a: Pointer to "struct tomoyo_path_info".
664 * @b: Pointer to "struct tomoyo_path_info".
666 * Returns true if @a == @b, false otherwise.
668 static inline bool tomoyo_pathcmp(const struct tomoyo_path_info *a,
669 const struct tomoyo_path_info *b)
671 return a->hash != b->hash || strcmp(a->name, b->name);
675 * tomoyo_valid - Check whether the character is a valid char.
677 * @c: The character to check.
679 * Returns true if @c is a valid character, false otherwise.
681 static inline bool tomoyo_valid(const unsigned char c)
683 return c > ' ' && c < 127;
687 * tomoyo_invalid - Check whether the character is an invalid char.
689 * @c: The character to check.
691 * Returns true if @c is an invalid character, false otherwise.
693 static inline bool tomoyo_invalid(const unsigned char c)
695 return c && (c <= ' ' || c >= 127);
699 * tomoyo_put_name - Drop reference on "struct tomoyo_name".
701 * @name: Pointer to "struct tomoyo_path_info". Maybe NULL.
705 static inline void tomoyo_put_name(const struct tomoyo_path_info *name)
708 struct tomoyo_name *ptr =
709 container_of(name, typeof(*ptr), entry);
710 atomic_dec(&ptr->users);
715 * tomoyo_put_group - Drop reference on "struct tomoyo_group".
717 * @group: Pointer to "struct tomoyo_group". Maybe NULL.
721 static inline void tomoyo_put_group(struct tomoyo_group *group)
724 atomic_dec(&group->users);
728 * tomoyo_domain - Get "struct tomoyo_domain_info" for current thread.
730 * Returns pointer to "struct tomoyo_domain_info" for current thread.
732 static inline struct tomoyo_domain_info *tomoyo_domain(void)
734 return current_cred()->security;
738 * tomoyo_real_domain - Get "struct tomoyo_domain_info" for specified thread.
740 * @task: Pointer to "struct task_struct".
742 * Returns pointer to "struct tomoyo_security" for specified thread.
744 static inline struct tomoyo_domain_info *tomoyo_real_domain(struct task_struct
747 return task_cred_xxx(task, security);
750 static inline bool tomoyo_same_acl_head(const struct tomoyo_acl_info *p1,
751 const struct tomoyo_acl_info *p2)
753 return p1->type == p2->type;
757 * tomoyo_same_name_union - Check for duplicated "struct tomoyo_name_union" entry.
759 * @a: Pointer to "struct tomoyo_name_union".
760 * @b: Pointer to "struct tomoyo_name_union".
762 * Returns true if @a == @b, false otherwise.
764 static inline bool tomoyo_same_name_union
765 (const struct tomoyo_name_union *a, const struct tomoyo_name_union *b)
767 return a->filename == b->filename && a->group == b->group &&
768 a->is_group == b->is_group;
772 * tomoyo_same_number_union - Check for duplicated "struct tomoyo_number_union" entry.
774 * @a: Pointer to "struct tomoyo_number_union".
775 * @b: Pointer to "struct tomoyo_number_union".
777 * Returns true if @a == @b, false otherwise.
779 static inline bool tomoyo_same_number_union
780 (const struct tomoyo_number_union *a, const struct tomoyo_number_union *b)
782 return a->values[0] == b->values[0] && a->values[1] == b->values[1] &&
783 a->group == b->group && a->min_type == b->min_type &&
784 a->max_type == b->max_type && a->is_group == b->is_group;
788 * list_for_each_cookie - iterate over a list with cookie.
789 * @pos: the &struct list_head to use as a loop cursor.
790 * @head: the head for your list.
792 #define list_for_each_cookie(pos, head) \
794 pos = srcu_dereference((head)->next, &tomoyo_ss); \
795 for ( ; pos != (head); pos = srcu_dereference(pos->next, &tomoyo_ss))
797 #endif /* !defined(_SECURITY_TOMOYO_COMMON_H) */