Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 1 | /* |
| 2 | * security/tomoyo/common.h |
| 3 | * |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 4 | * Header file for TOMOYO. |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 5 | * |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef _SECURITY_TOMOYO_COMMON_H |
| 10 | #define _SECURITY_TOMOYO_COMMON_H |
| 11 | |
| 12 | #include <linux/ctype.h> |
| 13 | #include <linux/string.h> |
| 14 | #include <linux/mm.h> |
| 15 | #include <linux/file.h> |
| 16 | #include <linux/kmod.h> |
| 17 | #include <linux/fs.h> |
| 18 | #include <linux/sched.h> |
| 19 | #include <linux/namei.h> |
| 20 | #include <linux/mount.h> |
| 21 | #include <linux/list.h> |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 22 | #include <linux/cred.h> |
Tetsuo Handa | 17fcfbd | 2010-05-17 10:11:36 +0900 | [diff] [blame] | 23 | #include <linux/poll.h> |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 24 | struct linux_binprm; |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 25 | |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 26 | /********** Constants definitions. **********/ |
| 27 | |
| 28 | /* |
| 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. |
| 32 | */ |
| 33 | #define TOMOYO_HASH_BITS 8 |
| 34 | #define TOMOYO_MAX_HASH (1u<<TOMOYO_HASH_BITS) |
| 35 | |
Tetsuo Handa | c8c57e8 | 2010-06-03 20:36:43 +0900 | [diff] [blame] | 36 | #define TOMOYO_EXEC_TMPSIZE 4096 |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 37 | |
| 38 | /* Profile number is an integer between 0 and 255. */ |
| 39 | #define TOMOYO_MAX_PROFILES 256 |
| 40 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 41 | /* Index numbers for operation mode. */ |
Tetsuo Handa | cb0abe6 | 2010-05-17 10:08:05 +0900 | [diff] [blame] | 42 | enum tomoyo_mode_index { |
| 43 | TOMOYO_CONFIG_DISABLED, |
| 44 | TOMOYO_CONFIG_LEARNING, |
| 45 | TOMOYO_CONFIG_PERMISSIVE, |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 46 | TOMOYO_CONFIG_ENFORCING, |
| 47 | TOMOYO_CONFIG_USE_DEFAULT = 255 |
Tetsuo Handa | cb0abe6 | 2010-05-17 10:08:05 +0900 | [diff] [blame] | 48 | }; |
| 49 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 50 | /* Index numbers for entry type. */ |
Tetsuo Handa | a230f9e | 2010-06-17 16:53:24 +0900 | [diff] [blame] | 51 | enum tomoyo_policy_id { |
| 52 | TOMOYO_ID_GROUP, |
| 53 | TOMOYO_ID_PATH_GROUP, |
| 54 | TOMOYO_ID_NUMBER_GROUP, |
Tetsuo Handa | 5448ec4 | 2010-06-21 11:14:39 +0900 | [diff] [blame] | 55 | TOMOYO_ID_TRANSITION_CONTROL, |
Tetsuo Handa | a230f9e | 2010-06-17 16:53:24 +0900 | [diff] [blame] | 56 | TOMOYO_ID_AGGREGATOR, |
Tetsuo Handa | a230f9e | 2010-06-17 16:53:24 +0900 | [diff] [blame] | 57 | TOMOYO_ID_MANAGER, |
| 58 | TOMOYO_ID_NAME, |
| 59 | TOMOYO_ID_ACL, |
| 60 | TOMOYO_ID_DOMAIN, |
| 61 | TOMOYO_MAX_POLICY |
| 62 | }; |
| 63 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 64 | /* Index numbers for group entries. */ |
Tetsuo Handa | a230f9e | 2010-06-17 16:53:24 +0900 | [diff] [blame] | 65 | enum tomoyo_group_id { |
| 66 | TOMOYO_PATH_GROUP, |
| 67 | TOMOYO_NUMBER_GROUP, |
| 68 | TOMOYO_MAX_GROUP |
| 69 | }; |
| 70 | |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 71 | /* A domain definition starts with <kernel>. */ |
| 72 | #define TOMOYO_ROOT_NAME "<kernel>" |
| 73 | #define TOMOYO_ROOT_NAME_LEN (sizeof(TOMOYO_ROOT_NAME) - 1) |
| 74 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 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, |
| 81 | }; |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 82 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 83 | /* Index numbers for domain transition control keywords. */ |
Tetsuo Handa | 5448ec4 | 2010-06-21 11:14:39 +0900 | [diff] [blame] | 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 |
| 91 | }; |
| 92 | |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 93 | /* Index numbers for Access Controls. */ |
Tetsuo Handa | 084da35 | 2010-02-15 15:10:39 +0900 | [diff] [blame] | 94 | enum tomoyo_acl_entry_type_index { |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 95 | TOMOYO_TYPE_PATH_ACL, |
| 96 | TOMOYO_TYPE_PATH2_ACL, |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 97 | TOMOYO_TYPE_PATH_NUMBER_ACL, |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 98 | TOMOYO_TYPE_MKDEV_ACL, |
Tetsuo Handa | 2106ccd | 2010-05-17 10:10:31 +0900 | [diff] [blame] | 99 | TOMOYO_TYPE_MOUNT_ACL, |
Tetsuo Handa | 084da35 | 2010-02-15 15:10:39 +0900 | [diff] [blame] | 100 | }; |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 101 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 102 | /* Index numbers for access controls with one pathname. */ |
Tetsuo Handa | 084da35 | 2010-02-15 15:10:39 +0900 | [diff] [blame] | 103 | enum tomoyo_path_acl_index { |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 104 | TOMOYO_TYPE_EXECUTE, |
| 105 | TOMOYO_TYPE_READ, |
| 106 | TOMOYO_TYPE_WRITE, |
Tetsuo Handa | 7c75964 | 2011-06-26 23:15:31 +0900 | [diff] [blame] | 107 | TOMOYO_TYPE_APPEND, |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 108 | TOMOYO_TYPE_UNLINK, |
Tetsuo Handa | 7c75964 | 2011-06-26 23:15:31 +0900 | [diff] [blame] | 109 | TOMOYO_TYPE_GETATTR, |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 110 | TOMOYO_TYPE_RMDIR, |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 111 | TOMOYO_TYPE_TRUNCATE, |
| 112 | TOMOYO_TYPE_SYMLINK, |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 113 | TOMOYO_TYPE_CHROOT, |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 114 | TOMOYO_TYPE_UMOUNT, |
| 115 | TOMOYO_MAX_PATH_OPERATION |
Tetsuo Handa | 084da35 | 2010-02-15 15:10:39 +0900 | [diff] [blame] | 116 | }; |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 117 | |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 118 | enum tomoyo_mkdev_acl_index { |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 119 | TOMOYO_TYPE_MKBLOCK, |
| 120 | TOMOYO_TYPE_MKCHAR, |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 121 | TOMOYO_MAX_MKDEV_OPERATION |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 122 | }; |
| 123 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 124 | /* Index numbers for access controls with two pathnames. */ |
Tetsuo Handa | 084da35 | 2010-02-15 15:10:39 +0900 | [diff] [blame] | 125 | enum tomoyo_path2_acl_index { |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 126 | TOMOYO_TYPE_LINK, |
| 127 | TOMOYO_TYPE_RENAME, |
| 128 | TOMOYO_TYPE_PIVOT_ROOT, |
| 129 | TOMOYO_MAX_PATH2_OPERATION |
Tetsuo Handa | 084da35 | 2010-02-15 15:10:39 +0900 | [diff] [blame] | 130 | }; |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 131 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 132 | /* Index numbers for access controls with one pathname and one number. */ |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 133 | enum tomoyo_path_number_acl_index { |
| 134 | TOMOYO_TYPE_CREATE, |
| 135 | TOMOYO_TYPE_MKDIR, |
| 136 | TOMOYO_TYPE_MKFIFO, |
| 137 | TOMOYO_TYPE_MKSOCK, |
| 138 | TOMOYO_TYPE_IOCTL, |
| 139 | TOMOYO_TYPE_CHMOD, |
| 140 | TOMOYO_TYPE_CHOWN, |
| 141 | TOMOYO_TYPE_CHGRP, |
| 142 | TOMOYO_MAX_PATH_NUMBER_OPERATION |
| 143 | }; |
| 144 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 145 | /* Index numbers for /sys/kernel/security/tomoyo/ interfaces. */ |
Tetsuo Handa | 084da35 | 2010-02-15 15:10:39 +0900 | [diff] [blame] | 146 | enum tomoyo_securityfs_interface_index { |
| 147 | TOMOYO_DOMAINPOLICY, |
| 148 | TOMOYO_EXCEPTIONPOLICY, |
| 149 | TOMOYO_DOMAIN_STATUS, |
| 150 | TOMOYO_PROCESS_STATUS, |
| 151 | TOMOYO_MEMINFO, |
| 152 | TOMOYO_SELFDOMAIN, |
| 153 | TOMOYO_VERSION, |
| 154 | TOMOYO_PROFILE, |
Tetsuo Handa | 17fcfbd | 2010-05-17 10:11:36 +0900 | [diff] [blame] | 155 | TOMOYO_QUERY, |
Tetsuo Handa | 084da35 | 2010-02-15 15:10:39 +0900 | [diff] [blame] | 156 | TOMOYO_MANAGER |
| 157 | }; |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 158 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 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 |
| 169 | }; |
| 170 | |
| 171 | /* Index numbers for functionality. */ |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 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, |
Tetsuo Handa | 7c75964 | 2011-06-26 23:15:31 +0900 | [diff] [blame] | 177 | TOMOYO_MAC_FILE_GETATTR, |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 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, |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 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, |
| 196 | TOMOYO_MAX_MAC_INDEX |
| 197 | }; |
| 198 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 199 | /* Index numbers for category of functionality. */ |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 200 | enum tomoyo_mac_category_index { |
| 201 | TOMOYO_MAC_CATEGORY_FILE, |
| 202 | TOMOYO_MAX_MAC_CATEGORY_INDEX |
| 203 | }; |
| 204 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 205 | /* |
| 206 | * Retry this request. Returned by tomoyo_supervisor() if policy violation has |
| 207 | * occurred in enforcing mode and the userspace daemon decided to retry. |
| 208 | * |
| 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". |
| 211 | */ |
| 212 | #define TOMOYO_RETRY_REQUEST 1 |
Tetsuo Handa | 17fcfbd | 2010-05-17 10:11:36 +0900 | [diff] [blame] | 213 | |
Tetsuo Handa | d5ca172 | 2011-06-26 23:18:21 +0900 | [diff] [blame^] | 214 | /* Index numbers for profile's PREFERENCE values. */ |
| 215 | enum tomoyo_pref_index { |
| 216 | TOMOYO_PREF_MAX_LEARNING_ENTRY, |
| 217 | TOMOYO_MAX_PREF |
| 218 | }; |
| 219 | |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 220 | /********** Structure definitions. **********/ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 221 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 222 | /* Common header for holding ACL entries. */ |
Tetsuo Handa | 82e0f00 | 2010-06-15 09:22:42 +0900 | [diff] [blame] | 223 | struct tomoyo_acl_head { |
| 224 | struct list_head list; |
| 225 | bool is_deleted; |
| 226 | } __packed; |
| 227 | |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 228 | /* Common header for shared entries. */ |
| 229 | struct tomoyo_shared_acl_head { |
| 230 | struct list_head list; |
| 231 | atomic_t users; |
| 232 | } __packed; |
| 233 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 234 | /* Structure for request info. */ |
Tetsuo Handa | cb0abe6 | 2010-05-17 10:08:05 +0900 | [diff] [blame] | 235 | struct tomoyo_request_info { |
| 236 | struct tomoyo_domain_info *domain; |
Tetsuo Handa | cf6e9a6 | 2010-06-16 16:21:36 +0900 | [diff] [blame] | 237 | /* For holding parameters. */ |
| 238 | union { |
| 239 | struct { |
| 240 | const struct tomoyo_path_info *filename; |
Tetsuo Handa | 484ca79 | 2010-07-29 14:29:55 +0900 | [diff] [blame] | 241 | /* For using wildcards at tomoyo_find_next_domain(). */ |
| 242 | const struct tomoyo_path_info *matched_path; |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 243 | /* One of values in "enum tomoyo_path_acl_index". */ |
Tetsuo Handa | cf6e9a6 | 2010-06-16 16:21:36 +0900 | [diff] [blame] | 244 | u8 operation; |
| 245 | } path; |
| 246 | struct { |
| 247 | const struct tomoyo_path_info *filename1; |
| 248 | const struct tomoyo_path_info *filename2; |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 249 | /* One of values in "enum tomoyo_path2_acl_index". */ |
Tetsuo Handa | cf6e9a6 | 2010-06-16 16:21:36 +0900 | [diff] [blame] | 250 | u8 operation; |
| 251 | } path2; |
| 252 | struct { |
| 253 | const struct tomoyo_path_info *filename; |
| 254 | unsigned int mode; |
| 255 | unsigned int major; |
| 256 | unsigned int minor; |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 257 | /* One of values in "enum tomoyo_mkdev_acl_index". */ |
Tetsuo Handa | cf6e9a6 | 2010-06-16 16:21:36 +0900 | [diff] [blame] | 258 | u8 operation; |
| 259 | } mkdev; |
| 260 | struct { |
| 261 | const struct tomoyo_path_info *filename; |
| 262 | unsigned long number; |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 263 | /* |
| 264 | * One of values in |
| 265 | * "enum tomoyo_path_number_acl_index". |
| 266 | */ |
Tetsuo Handa | cf6e9a6 | 2010-06-16 16:21:36 +0900 | [diff] [blame] | 267 | u8 operation; |
| 268 | } path_number; |
| 269 | struct { |
| 270 | const struct tomoyo_path_info *type; |
| 271 | const struct tomoyo_path_info *dir; |
| 272 | const struct tomoyo_path_info *dev; |
| 273 | unsigned long flags; |
| 274 | int need_dev; |
| 275 | } mount; |
| 276 | } param; |
| 277 | u8 param_type; |
| 278 | bool granted; |
Tetsuo Handa | 17fcfbd | 2010-05-17 10:11:36 +0900 | [diff] [blame] | 279 | u8 retry; |
| 280 | u8 profile; |
Tetsuo Handa | cb0abe6 | 2010-05-17 10:08:05 +0900 | [diff] [blame] | 281 | u8 mode; /* One of tomoyo_mode_index . */ |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 282 | u8 type; |
Tetsuo Handa | cb0abe6 | 2010-05-17 10:08:05 +0900 | [diff] [blame] | 283 | }; |
| 284 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 285 | /* Structure for holding a token. */ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 286 | struct tomoyo_path_info { |
| 287 | const char *name; |
| 288 | u32 hash; /* = full_name_hash(name, strlen(name)) */ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 289 | u16 const_len; /* = tomoyo_const_part_length(name) */ |
| 290 | bool is_dir; /* = tomoyo_strendswith(name, "/") */ |
| 291 | bool is_patterned; /* = tomoyo_path_contains_pattern(name) */ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 292 | }; |
| 293 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 294 | /* Structure for holding string data. */ |
Tetsuo Handa | e2bf690 | 2010-06-25 11:16:00 +0900 | [diff] [blame] | 295 | struct tomoyo_name { |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 296 | struct tomoyo_shared_acl_head head; |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 297 | struct tomoyo_path_info entry; |
| 298 | }; |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 299 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 300 | /* Structure for holding a word. */ |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 301 | struct tomoyo_name_union { |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 302 | /* Either @filename or @group is NULL. */ |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 303 | const struct tomoyo_path_info *filename; |
Tetsuo Handa | a98aa4d | 2010-06-17 16:52:29 +0900 | [diff] [blame] | 304 | struct tomoyo_group *group; |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 305 | }; |
| 306 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 307 | /* Structure for holding a number. */ |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 308 | struct tomoyo_number_union { |
| 309 | unsigned long values[2]; |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 310 | struct tomoyo_group *group; /* Maybe NULL. */ |
| 311 | /* One of values in "enum tomoyo_value_type". */ |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 312 | u8 value_type[2]; |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 313 | }; |
| 314 | |
Tetsuo Handa | a98aa4d | 2010-06-17 16:52:29 +0900 | [diff] [blame] | 315 | /* Structure for "path_group"/"number_group" directive. */ |
| 316 | struct tomoyo_group { |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 317 | struct tomoyo_shared_acl_head head; |
Tetsuo Handa | a98aa4d | 2010-06-17 16:52:29 +0900 | [diff] [blame] | 318 | const struct tomoyo_path_info *group_name; |
| 319 | struct list_head member_list; |
Tetsuo Handa | a98aa4d | 2010-06-17 16:52:29 +0900 | [diff] [blame] | 320 | }; |
| 321 | |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 322 | /* Structure for "path_group" directive. */ |
| 323 | struct tomoyo_path_group { |
Tetsuo Handa | 82e0f00 | 2010-06-15 09:22:42 +0900 | [diff] [blame] | 324 | struct tomoyo_acl_head head; |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 325 | const struct tomoyo_path_info *member_name; |
| 326 | }; |
| 327 | |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 328 | /* Structure for "number_group" directive. */ |
Tetsuo Handa | a98aa4d | 2010-06-17 16:52:29 +0900 | [diff] [blame] | 329 | struct tomoyo_number_group { |
Tetsuo Handa | 82e0f00 | 2010-06-15 09:22:42 +0900 | [diff] [blame] | 330 | struct tomoyo_acl_head head; |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 331 | struct tomoyo_number_union number; |
| 332 | }; |
| 333 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 334 | /* Common header for individual entries. */ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 335 | struct tomoyo_acl_info { |
| 336 | struct list_head list; |
Tetsuo Handa | 237ab45 | 2010-06-12 20:46:22 +0900 | [diff] [blame] | 337 | bool is_deleted; |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 338 | u8 type; /* One of values in "enum tomoyo_acl_entry_type_index". */ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 339 | } __packed; |
| 340 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 341 | /* Structure for domain information. */ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 342 | struct tomoyo_domain_info { |
| 343 | struct list_head list; |
| 344 | struct list_head acl_info_list; |
| 345 | /* Name of this domain. Never NULL. */ |
| 346 | const struct tomoyo_path_info *domainname; |
| 347 | u8 profile; /* Profile number to use. */ |
Tetsuo Handa | a0558fc | 2009-04-06 20:49:14 +0900 | [diff] [blame] | 348 | bool is_deleted; /* Delete flag. */ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 349 | bool quota_warned; /* Quota warnning flag. */ |
Tetsuo Handa | ea13ddb | 2010-02-03 06:43:06 +0900 | [diff] [blame] | 350 | bool transition_failed; /* Domain transition failed flag. */ |
Tetsuo Handa | ec8e6a4 | 2010-02-11 09:43:20 +0900 | [diff] [blame] | 351 | atomic_t users; /* Number of referring credentials. */ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 352 | }; |
| 353 | |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 354 | /* |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 355 | * Structure for "file execute", "file read", "file write", "file append", |
| 356 | * "file unlink", "file getattr", "file rmdir", "file truncate", |
| 357 | * "file symlink", "file chroot" and "file unmount" directive. |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 358 | */ |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 359 | struct tomoyo_path_acl { |
| 360 | struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH_ACL */ |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 361 | u16 perm; /* Bitmask of values in "enum tomoyo_path_acl_index". */ |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 362 | struct tomoyo_name_union name; |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 363 | }; |
| 364 | |
Tetsuo Handa | c3fa109 | 2009-06-08 12:37:39 +0900 | [diff] [blame] | 365 | /* |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 366 | * Structure for "file create", "file mkdir", "file mkfifo", "file mksock", |
| 367 | * "file ioctl", "file chmod", "file chown" and "file chgrp" directive. |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 368 | */ |
| 369 | struct tomoyo_path_number_acl { |
| 370 | struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH_NUMBER_ACL */ |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 371 | /* Bitmask of values in "enum tomoyo_path_number_acl_index". */ |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 372 | u8 perm; |
| 373 | struct tomoyo_name_union name; |
| 374 | struct tomoyo_number_union number; |
| 375 | }; |
| 376 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 377 | /* Structure for "file mkblock" and "file mkchar" directive. */ |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 378 | struct tomoyo_mkdev_acl { |
| 379 | struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_MKDEV_ACL */ |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 380 | u8 perm; /* Bitmask of values in "enum tomoyo_mkdev_acl_index". */ |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 381 | struct tomoyo_name_union name; |
| 382 | struct tomoyo_number_union mode; |
| 383 | struct tomoyo_number_union major; |
| 384 | struct tomoyo_number_union minor; |
| 385 | }; |
| 386 | |
| 387 | /* |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 388 | * Structure for "file rename", "file link" and "file pivot_root" directive. |
Tetsuo Handa | c3fa109 | 2009-06-08 12:37:39 +0900 | [diff] [blame] | 389 | */ |
Tetsuo Handa | 7ef6123 | 2010-02-16 08:03:30 +0900 | [diff] [blame] | 390 | struct tomoyo_path2_acl { |
| 391 | struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH2_ACL */ |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 392 | u8 perm; /* Bitmask of values in "enum tomoyo_path2_acl_index". */ |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 393 | struct tomoyo_name_union name1; |
| 394 | struct tomoyo_name_union name2; |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 395 | }; |
| 396 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 397 | /* Structure for "file mount" directive. */ |
Tetsuo Handa | 2106ccd | 2010-05-17 10:10:31 +0900 | [diff] [blame] | 398 | struct tomoyo_mount_acl { |
| 399 | struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_MOUNT_ACL */ |
Tetsuo Handa | 2106ccd | 2010-05-17 10:10:31 +0900 | [diff] [blame] | 400 | struct tomoyo_name_union dev_name; |
| 401 | struct tomoyo_name_union dir_name; |
| 402 | struct tomoyo_name_union fs_type; |
| 403 | struct tomoyo_number_union flags; |
| 404 | }; |
| 405 | |
Tetsuo Handa | a238cf5 | 2011-06-26 23:17:10 +0900 | [diff] [blame] | 406 | /* Structure for holding a line from /sys/kernel/security/tomoyo/ interface. */ |
| 407 | struct tomoyo_acl_param { |
| 408 | char *data; |
| 409 | struct list_head *list; |
| 410 | bool is_delete; |
| 411 | }; |
| 412 | |
Tetsuo Handa | 0d2171d | 2011-06-26 23:17:46 +0900 | [diff] [blame] | 413 | #define TOMOYO_MAX_IO_READ_QUEUE 64 |
Tetsuo Handa | f23571e | 2010-06-24 14:57:16 +0900 | [diff] [blame] | 414 | |
Tetsuo Handa | 2106ccd | 2010-05-17 10:10:31 +0900 | [diff] [blame] | 415 | /* |
Tetsuo Handa | f23571e | 2010-06-24 14:57:16 +0900 | [diff] [blame] | 416 | * Structure for reading/writing policy via /sys/kernel/security/tomoyo |
| 417 | * interfaces. |
Tetsuo Handa | c3fa109 | 2009-06-08 12:37:39 +0900 | [diff] [blame] | 418 | */ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 419 | struct tomoyo_io_buffer { |
Tetsuo Handa | 8fbe71f | 2010-06-16 16:29:59 +0900 | [diff] [blame] | 420 | void (*read) (struct tomoyo_io_buffer *); |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 421 | int (*write) (struct tomoyo_io_buffer *); |
Tetsuo Handa | 17fcfbd | 2010-05-17 10:11:36 +0900 | [diff] [blame] | 422 | int (*poll) (struct file *file, poll_table *wait); |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 423 | /* Exclusive lock for this structure. */ |
| 424 | struct mutex io_sem; |
Tetsuo Handa | fdb8ebb | 2009-12-08 09:34:43 +0900 | [diff] [blame] | 425 | /* Index returned by tomoyo_read_lock(). */ |
| 426 | int reader_idx; |
Tetsuo Handa | f23571e | 2010-06-24 14:57:16 +0900 | [diff] [blame] | 427 | char __user *read_user_buf; |
| 428 | int read_user_buf_avail; |
| 429 | struct { |
| 430 | struct list_head *domain; |
| 431 | struct list_head *group; |
| 432 | struct list_head *acl; |
| 433 | int avail; |
| 434 | int step; |
| 435 | int query_index; |
| 436 | u16 index; |
| 437 | u8 bit; |
| 438 | u8 w_pos; |
| 439 | bool eof; |
| 440 | bool print_this_domain_only; |
| 441 | bool print_execute_only; |
| 442 | const char *w[TOMOYO_MAX_IO_READ_QUEUE]; |
| 443 | } r; |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 444 | struct { |
| 445 | /* The position currently writing to. */ |
| 446 | struct tomoyo_domain_info *domain; |
| 447 | /* Bytes available for writing. */ |
| 448 | int avail; |
| 449 | } w; |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 450 | /* Buffer for reading. */ |
| 451 | char *read_buf; |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 452 | /* Size of read buffer. */ |
| 453 | int readbuf_size; |
| 454 | /* Buffer for writing. */ |
| 455 | char *write_buf; |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 456 | /* Size of write buffer. */ |
| 457 | int writebuf_size; |
Tetsuo Handa | 17fcfbd | 2010-05-17 10:11:36 +0900 | [diff] [blame] | 458 | /* Type of this interface. */ |
| 459 | u8 type; |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 460 | }; |
| 461 | |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 462 | /* |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 463 | * Structure for "initialize_domain"/"no_initialize_domain"/"keep_domain"/ |
| 464 | * "no_keep_domain" keyword. |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 465 | */ |
Tetsuo Handa | 5448ec4 | 2010-06-21 11:14:39 +0900 | [diff] [blame] | 466 | struct tomoyo_transition_control { |
Tetsuo Handa | 82e0f00 | 2010-06-15 09:22:42 +0900 | [diff] [blame] | 467 | struct tomoyo_acl_head head; |
Tetsuo Handa | 5448ec4 | 2010-06-21 11:14:39 +0900 | [diff] [blame] | 468 | u8 type; /* One of values in "enum tomoyo_transition_type". */ |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 469 | /* True if the domainname is tomoyo_get_last_name(). */ |
| 470 | bool is_last_name; |
Tetsuo Handa | 5448ec4 | 2010-06-21 11:14:39 +0900 | [diff] [blame] | 471 | const struct tomoyo_path_info *domainname; /* Maybe NULL */ |
| 472 | const struct tomoyo_path_info *program; /* Maybe NULL */ |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 473 | }; |
| 474 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 475 | /* Structure for "aggregator" keyword. */ |
Tetsuo Handa | e2bf690 | 2010-06-25 11:16:00 +0900 | [diff] [blame] | 476 | struct tomoyo_aggregator { |
Tetsuo Handa | 82e0f00 | 2010-06-15 09:22:42 +0900 | [diff] [blame] | 477 | struct tomoyo_acl_head head; |
Tetsuo Handa | 1084307 | 2010-06-03 20:38:03 +0900 | [diff] [blame] | 478 | const struct tomoyo_path_info *original_name; |
| 479 | const struct tomoyo_path_info *aggregated_name; |
Tetsuo Handa | 1084307 | 2010-06-03 20:38:03 +0900 | [diff] [blame] | 480 | }; |
| 481 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 482 | /* Structure for policy manager. */ |
Tetsuo Handa | e2bf690 | 2010-06-25 11:16:00 +0900 | [diff] [blame] | 483 | struct tomoyo_manager { |
Tetsuo Handa | 82e0f00 | 2010-06-15 09:22:42 +0900 | [diff] [blame] | 484 | struct tomoyo_acl_head head; |
| 485 | bool is_domain; /* True if manager is a domainname. */ |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 486 | /* A path to program or a domainname. */ |
| 487 | const struct tomoyo_path_info *manager; |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 488 | }; |
| 489 | |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 490 | struct tomoyo_preference { |
| 491 | unsigned int learning_max_entry; |
| 492 | bool enforcing_verbose; |
| 493 | bool learning_verbose; |
| 494 | bool permissive_verbose; |
| 495 | }; |
| 496 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 497 | /* Structure for /sys/kernel/security/tomnoyo/profile interface. */ |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 498 | struct tomoyo_profile { |
| 499 | const struct tomoyo_path_info *comment; |
| 500 | struct tomoyo_preference *learning; |
| 501 | struct tomoyo_preference *permissive; |
| 502 | struct tomoyo_preference *enforcing; |
| 503 | struct tomoyo_preference preference; |
| 504 | u8 default_config; |
| 505 | u8 config[TOMOYO_MAX_MAC_INDEX + TOMOYO_MAX_MAC_CATEGORY_INDEX]; |
Tetsuo Handa | d5ca172 | 2011-06-26 23:18:21 +0900 | [diff] [blame^] | 506 | unsigned int pref[TOMOYO_MAX_PREF]; |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 507 | }; |
| 508 | |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 509 | /********** Function prototypes. **********/ |
| 510 | |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 511 | bool tomoyo_str_starts(char **src, const char *find); |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 512 | const char *tomoyo_get_exe(void); |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 513 | void tomoyo_normalize_line(unsigned char *buffer); |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 514 | void tomoyo_warn_log(struct tomoyo_request_info *r, const char *fmt, ...) |
| 515 | __attribute__ ((format(printf, 2, 3))); |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 516 | void tomoyo_check_profile(void); |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 517 | int tomoyo_open_control(const u8 type, struct file *file); |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 518 | int tomoyo_close_control(struct tomoyo_io_buffer *head); |
Tetsuo Handa | 0849e3b | 2010-06-25 12:22:09 +0900 | [diff] [blame] | 519 | int tomoyo_poll_control(struct file *file, poll_table *wait); |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 520 | int tomoyo_read_control(struct tomoyo_io_buffer *head, char __user *buffer, |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 521 | const int buffer_len); |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 522 | int tomoyo_write_control(struct tomoyo_io_buffer *head, |
| 523 | const char __user *buffer, const int buffer_len); |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 524 | bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r); |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 525 | void tomoyo_warn_oom(const char *function); |
Tetsuo Handa | 484ca79 | 2010-07-29 14:29:55 +0900 | [diff] [blame] | 526 | const struct tomoyo_path_info * |
| 527 | tomoyo_compare_name_union(const struct tomoyo_path_info *name, |
| 528 | const struct tomoyo_name_union *ptr); |
Tetsuo Handa | 2106ccd | 2010-05-17 10:10:31 +0900 | [diff] [blame] | 529 | bool tomoyo_compare_number_union(const unsigned long value, |
| 530 | const struct tomoyo_number_union *ptr); |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 531 | int tomoyo_get_mode(const u8 profile, const u8 index); |
Tetsuo Handa | f23571e | 2010-06-24 14:57:16 +0900 | [diff] [blame] | 532 | void tomoyo_io_printf(struct tomoyo_io_buffer *head, const char *fmt, ...) |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 533 | __attribute__ ((format(printf, 2, 3))); |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 534 | bool tomoyo_correct_domain(const unsigned char *domainname); |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 535 | bool tomoyo_correct_path(const char *filename); |
| 536 | bool tomoyo_correct_word(const char *string); |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 537 | bool tomoyo_domain_def(const unsigned char *buffer); |
Tetsuo Handa | a238cf5 | 2011-06-26 23:17:10 +0900 | [diff] [blame] | 538 | bool tomoyo_parse_name_union(struct tomoyo_acl_param *param, |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 539 | struct tomoyo_name_union *ptr); |
Tetsuo Handa | 484ca79 | 2010-07-29 14:29:55 +0900 | [diff] [blame] | 540 | const struct tomoyo_path_info * |
| 541 | tomoyo_path_matches_group(const struct tomoyo_path_info *pathname, |
| 542 | const struct tomoyo_group *group); |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 543 | bool tomoyo_number_matches_group(const unsigned long min, |
| 544 | const unsigned long max, |
Tetsuo Handa | a98aa4d | 2010-06-17 16:52:29 +0900 | [diff] [blame] | 545 | const struct tomoyo_group *group); |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 546 | bool tomoyo_path_matches_pattern(const struct tomoyo_path_info *filename, |
| 547 | const struct tomoyo_path_info *pattern); |
Tetsuo Handa | a238cf5 | 2011-06-26 23:17:10 +0900 | [diff] [blame] | 548 | bool tomoyo_parse_number_union(struct tomoyo_acl_param *param, |
| 549 | struct tomoyo_number_union *ptr); |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 550 | bool tomoyo_tokenize(char *buffer, char *w[], size_t size); |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 551 | bool tomoyo_verbose_mode(const struct tomoyo_domain_info *domain); |
Tetsuo Handa | 2106ccd | 2010-05-17 10:10:31 +0900 | [diff] [blame] | 552 | int tomoyo_init_request_info(struct tomoyo_request_info *r, |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 553 | struct tomoyo_domain_info *domain, |
| 554 | const u8 index); |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 555 | int tomoyo_mount_permission(char *dev_name, struct path *path, |
| 556 | const char *type, unsigned long flags, |
| 557 | void *data_page); |
Tetsuo Handa | a238cf5 | 2011-06-26 23:17:10 +0900 | [diff] [blame] | 558 | int tomoyo_write_aggregator(struct tomoyo_acl_param *param); |
| 559 | int tomoyo_write_transition_control(struct tomoyo_acl_param *param, |
Tetsuo Handa | 5448ec4 | 2010-06-21 11:14:39 +0900 | [diff] [blame] | 560 | const u8 type); |
Tetsuo Handa | a238cf5 | 2011-06-26 23:17:10 +0900 | [diff] [blame] | 561 | int tomoyo_write_file(struct tomoyo_acl_param *param); |
| 562 | int tomoyo_write_group(struct tomoyo_acl_param *param, const u8 type); |
Tetsuo Handa | 17fcfbd | 2010-05-17 10:11:36 +0900 | [diff] [blame] | 563 | int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...) |
| 564 | __attribute__ ((format(printf, 2, 3))); |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 565 | struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname); |
Tetsuo Handa | e2bf690 | 2010-06-25 11:16:00 +0900 | [diff] [blame] | 566 | struct tomoyo_domain_info *tomoyo_assign_domain(const char *domainname, |
| 567 | const u8 profile); |
Tetsuo Handa | 57c2590 | 2010-06-03 20:38:44 +0900 | [diff] [blame] | 568 | struct tomoyo_profile *tomoyo_profile(const u8 profile); |
Tetsuo Handa | a238cf5 | 2011-06-26 23:17:10 +0900 | [diff] [blame] | 569 | struct tomoyo_group *tomoyo_get_group(struct tomoyo_acl_param *param, |
| 570 | const u8 idx); |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 571 | unsigned int tomoyo_check_flags(const struct tomoyo_domain_info *domain, |
| 572 | const u8 index); |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 573 | void tomoyo_fill_path_info(struct tomoyo_path_info *ptr); |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 574 | void tomoyo_load_policy(const char *filename); |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 575 | void tomoyo_put_number_union(struct tomoyo_number_union *ptr); |
Tetsuo Handa | c8c57e8 | 2010-06-03 20:36:43 +0900 | [diff] [blame] | 576 | char *tomoyo_encode(const char *str); |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 577 | char *tomoyo_realpath_nofollow(const char *pathname); |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 578 | char *tomoyo_realpath_from_path(struct path *path); |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 579 | bool tomoyo_memory_ok(void *ptr); |
Tetsuo Handa | 9e4b50e | 2010-05-06 12:40:02 +0900 | [diff] [blame] | 580 | void *tomoyo_commit_ok(void *data, const unsigned int size); |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 581 | const struct tomoyo_path_info *tomoyo_get_name(const char *name); |
Tetsuo Handa | 8fbe71f | 2010-06-16 16:29:59 +0900 | [diff] [blame] | 582 | void tomoyo_read_memory_counter(struct tomoyo_io_buffer *head); |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 583 | int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head); |
Tetsuo Handa | c3ef150 | 2010-05-17 10:12:46 +0900 | [diff] [blame] | 584 | void __init tomoyo_mm_init(void); |
Tetsuo Handa | 05336de | 2010-06-16 16:20:24 +0900 | [diff] [blame] | 585 | int tomoyo_path_permission(struct tomoyo_request_info *r, u8 operation, |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 586 | const struct tomoyo_path_info *filename); |
| 587 | int tomoyo_check_open_permission(struct tomoyo_domain_info *domain, |
| 588 | struct path *path, const int flag); |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 589 | int tomoyo_path_number_perm(const u8 operation, struct path *path, |
| 590 | unsigned long number); |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 591 | int tomoyo_mkdev_perm(const u8 operation, struct path *path, |
| 592 | const unsigned int mode, unsigned int dev); |
Tetsuo Handa | 97d6931 | 2010-02-16 09:46:15 +0900 | [diff] [blame] | 593 | int tomoyo_path_perm(const u8 operation, struct path *path); |
| 594 | int tomoyo_path2_perm(const u8 operation, struct path *path1, |
| 595 | struct path *path2); |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 596 | int tomoyo_find_next_domain(struct linux_binprm *bprm); |
Tetsuo Handa | a1f9bb6 | 2010-05-17 10:09:15 +0900 | [diff] [blame] | 597 | void tomoyo_print_ulong(char *buffer, const int buffer_len, |
| 598 | const unsigned long value, const u8 type); |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 599 | void tomoyo_put_name_union(struct tomoyo_name_union *ptr); |
Tetsuo Handa | 847b173 | 2010-02-11 09:43:54 +0900 | [diff] [blame] | 600 | void tomoyo_run_gc(void); |
Tetsuo Handa | 847b173 | 2010-02-11 09:43:54 +0900 | [diff] [blame] | 601 | void tomoyo_memory_free(void *ptr); |
Tetsuo Handa | 237ab45 | 2010-06-12 20:46:22 +0900 | [diff] [blame] | 602 | int tomoyo_update_domain(struct tomoyo_acl_info *new_entry, const int size, |
Tetsuo Handa | a238cf5 | 2011-06-26 23:17:10 +0900 | [diff] [blame] | 603 | struct tomoyo_acl_param *param, |
Tetsuo Handa | 237ab45 | 2010-06-12 20:46:22 +0900 | [diff] [blame] | 604 | bool (*check_duplicate) (const struct tomoyo_acl_info |
| 605 | *, |
| 606 | const struct tomoyo_acl_info |
| 607 | *), |
| 608 | bool (*merge_duplicate) (struct tomoyo_acl_info *, |
| 609 | struct tomoyo_acl_info *, |
| 610 | const bool)); |
Tetsuo Handa | 36f5e1f | 2010-06-15 09:23:26 +0900 | [diff] [blame] | 611 | int tomoyo_update_policy(struct tomoyo_acl_head *new_entry, const int size, |
Tetsuo Handa | a238cf5 | 2011-06-26 23:17:10 +0900 | [diff] [blame] | 612 | struct tomoyo_acl_param *param, |
Tetsuo Handa | 36f5e1f | 2010-06-15 09:23:26 +0900 | [diff] [blame] | 613 | bool (*check_duplicate) (const struct tomoyo_acl_head |
| 614 | *, |
| 615 | const struct tomoyo_acl_head |
| 616 | *)); |
Tetsuo Handa | 99a8525 | 2010-06-16 16:22:51 +0900 | [diff] [blame] | 617 | void tomoyo_check_acl(struct tomoyo_request_info *r, |
Tetsuo Handa | 484ca79 | 2010-07-29 14:29:55 +0900 | [diff] [blame] | 618 | bool (*check_entry) (struct tomoyo_request_info *, |
Tetsuo Handa | 99a8525 | 2010-06-16 16:22:51 +0900 | [diff] [blame] | 619 | const struct tomoyo_acl_info *)); |
Tetsuo Handa | a238cf5 | 2011-06-26 23:17:10 +0900 | [diff] [blame] | 620 | char *tomoyo_read_token(struct tomoyo_acl_param *param); |
| 621 | bool tomoyo_permstr(const char *string, const char *keyword); |
Tetsuo Handa | 237ab45 | 2010-06-12 20:46:22 +0900 | [diff] [blame] | 622 | |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 623 | /********** External variable definitions. **********/ |
| 624 | |
| 625 | /* Lock for GC. */ |
| 626 | extern struct srcu_struct tomoyo_ss; |
| 627 | |
| 628 | /* The list for "struct tomoyo_domain_info". */ |
| 629 | extern struct list_head tomoyo_domain_list; |
| 630 | |
Tetsuo Handa | a230f9e | 2010-06-17 16:53:24 +0900 | [diff] [blame] | 631 | extern struct list_head tomoyo_policy_list[TOMOYO_MAX_POLICY]; |
| 632 | extern struct list_head tomoyo_group_list[TOMOYO_MAX_GROUP]; |
Tetsuo Handa | 847b173 | 2010-02-11 09:43:54 +0900 | [diff] [blame] | 633 | extern struct list_head tomoyo_name_list[TOMOYO_MAX_HASH]; |
Tetsuo Handa | 847b173 | 2010-02-11 09:43:54 +0900 | [diff] [blame] | 634 | |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 635 | /* Lock for protecting policy. */ |
| 636 | extern struct mutex tomoyo_policy_lock; |
| 637 | |
| 638 | /* Has /sbin/init started? */ |
| 639 | extern bool tomoyo_policy_loaded; |
| 640 | |
| 641 | /* The kernel's domain. */ |
| 642 | extern struct tomoyo_domain_info tomoyo_kernel_domain; |
| 643 | |
Tetsuo Handa | 71c2823 | 2010-06-16 16:26:38 +0900 | [diff] [blame] | 644 | extern const char *tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION]; |
| 645 | extern const char *tomoyo_mkdev_keyword[TOMOYO_MAX_MKDEV_OPERATION]; |
| 646 | extern const char *tomoyo_path2_keyword[TOMOYO_MAX_PATH2_OPERATION]; |
| 647 | extern const char *tomoyo_path_number_keyword[TOMOYO_MAX_PATH_NUMBER_OPERATION]; |
| 648 | |
Tetsuo Handa | 0d2171d | 2011-06-26 23:17:46 +0900 | [diff] [blame] | 649 | extern const u8 tomoyo_pnnn2mac[TOMOYO_MAX_MKDEV_OPERATION]; |
| 650 | extern const u8 tomoyo_pp2mac[TOMOYO_MAX_PATH2_OPERATION]; |
| 651 | extern const u8 tomoyo_pn2mac[TOMOYO_MAX_PATH_NUMBER_OPERATION]; |
| 652 | |
Tetsuo Handa | 17fcfbd | 2010-05-17 10:11:36 +0900 | [diff] [blame] | 653 | extern unsigned int tomoyo_quota_for_query; |
| 654 | extern unsigned int tomoyo_query_memory_size; |
| 655 | |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 656 | /********** Inlined functions. **********/ |
| 657 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 658 | /** |
| 659 | * tomoyo_read_lock - Take lock for protecting policy. |
| 660 | * |
| 661 | * Returns index number for tomoyo_read_unlock(). |
| 662 | */ |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 663 | static inline int tomoyo_read_lock(void) |
| 664 | { |
| 665 | return srcu_read_lock(&tomoyo_ss); |
| 666 | } |
| 667 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 668 | /** |
| 669 | * tomoyo_read_unlock - Release lock for protecting policy. |
| 670 | * |
| 671 | * @idx: Index number returned by tomoyo_read_lock(). |
| 672 | * |
| 673 | * Returns nothing. |
| 674 | */ |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 675 | static inline void tomoyo_read_unlock(int idx) |
| 676 | { |
| 677 | srcu_read_unlock(&tomoyo_ss, idx); |
| 678 | } |
| 679 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 680 | /** |
| 681 | * tomoyo_pathcmp - strcmp() for "struct tomoyo_path_info" structure. |
| 682 | * |
| 683 | * @a: Pointer to "struct tomoyo_path_info". |
| 684 | * @b: Pointer to "struct tomoyo_path_info". |
| 685 | * |
| 686 | * Returns true if @a == @b, false otherwise. |
| 687 | */ |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 688 | static inline bool tomoyo_pathcmp(const struct tomoyo_path_info *a, |
| 689 | const struct tomoyo_path_info *b) |
| 690 | { |
| 691 | return a->hash != b->hash || strcmp(a->name, b->name); |
| 692 | } |
| 693 | |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 694 | /** |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 695 | * tomoyo_put_name - Drop reference on "struct tomoyo_name". |
| 696 | * |
| 697 | * @name: Pointer to "struct tomoyo_path_info". Maybe NULL. |
| 698 | * |
| 699 | * Returns nothing. |
| 700 | */ |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 701 | static inline void tomoyo_put_name(const struct tomoyo_path_info *name) |
| 702 | { |
| 703 | if (name) { |
Tetsuo Handa | e2bf690 | 2010-06-25 11:16:00 +0900 | [diff] [blame] | 704 | struct tomoyo_name *ptr = |
| 705 | container_of(name, typeof(*ptr), entry); |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 706 | atomic_dec(&ptr->head.users); |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 707 | } |
| 708 | } |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 709 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 710 | /** |
| 711 | * tomoyo_put_group - Drop reference on "struct tomoyo_group". |
| 712 | * |
| 713 | * @group: Pointer to "struct tomoyo_group". Maybe NULL. |
| 714 | * |
| 715 | * Returns nothing. |
| 716 | */ |
Tetsuo Handa | a98aa4d | 2010-06-17 16:52:29 +0900 | [diff] [blame] | 717 | static inline void tomoyo_put_group(struct tomoyo_group *group) |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 718 | { |
| 719 | if (group) |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 720 | atomic_dec(&group->head.users); |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 721 | } |
| 722 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 723 | /** |
| 724 | * tomoyo_domain - Get "struct tomoyo_domain_info" for current thread. |
| 725 | * |
| 726 | * Returns pointer to "struct tomoyo_domain_info" for current thread. |
| 727 | */ |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 728 | static inline struct tomoyo_domain_info *tomoyo_domain(void) |
| 729 | { |
| 730 | return current_cred()->security; |
| 731 | } |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 732 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 733 | /** |
| 734 | * tomoyo_real_domain - Get "struct tomoyo_domain_info" for specified thread. |
| 735 | * |
| 736 | * @task: Pointer to "struct task_struct". |
| 737 | * |
| 738 | * Returns pointer to "struct tomoyo_security" for specified thread. |
| 739 | */ |
Tetsuo Handa | 76bb089 | 2010-02-11 09:42:40 +0900 | [diff] [blame] | 740 | static inline struct tomoyo_domain_info *tomoyo_real_domain(struct task_struct |
| 741 | *task) |
| 742 | { |
| 743 | return task_cred_xxx(task, security); |
| 744 | } |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 745 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 746 | /** |
| 747 | * tomoyo_same_name_union - Check for duplicated "struct tomoyo_name_union" entry. |
| 748 | * |
| 749 | * @a: Pointer to "struct tomoyo_name_union". |
| 750 | * @b: Pointer to "struct tomoyo_name_union". |
| 751 | * |
| 752 | * Returns true if @a == @b, false otherwise. |
| 753 | */ |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 754 | static inline bool tomoyo_same_name_union |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 755 | (const struct tomoyo_name_union *a, const struct tomoyo_name_union *b) |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 756 | { |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 757 | return a->filename == b->filename && a->group == b->group; |
Tetsuo Handa | 7762fbf | 2010-05-10 17:30:26 +0900 | [diff] [blame] | 758 | } |
| 759 | |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 760 | /** |
| 761 | * tomoyo_same_number_union - Check for duplicated "struct tomoyo_number_union" entry. |
| 762 | * |
| 763 | * @a: Pointer to "struct tomoyo_number_union". |
| 764 | * @b: Pointer to "struct tomoyo_number_union". |
| 765 | * |
| 766 | * Returns true if @a == @b, false otherwise. |
| 767 | */ |
Tetsuo Handa | 7509315 | 2010-06-16 16:23:55 +0900 | [diff] [blame] | 768 | static inline bool tomoyo_same_number_union |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 769 | (const struct tomoyo_number_union *a, const struct tomoyo_number_union *b) |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 770 | { |
Tetsuo Handa | b5bc60b | 2011-06-26 23:16:03 +0900 | [diff] [blame] | 771 | return a->values[0] == b->values[0] && a->values[1] == b->values[1] && |
Tetsuo Handa | 0df7e8b | 2011-06-26 23:16:36 +0900 | [diff] [blame] | 772 | a->group == b->group && a->value_type[0] == b->value_type[0] && |
| 773 | a->value_type[1] == b->value_type[1]; |
Tetsuo Handa | 4c3e9e2 | 2010-05-17 10:06:58 +0900 | [diff] [blame] | 774 | } |
| 775 | |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 776 | /** |
| 777 | * list_for_each_cookie - iterate over a list with cookie. |
| 778 | * @pos: the &struct list_head to use as a loop cursor. |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 779 | * @head: the head for your list. |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 780 | */ |
Tetsuo Handa | 475e6fa | 2010-06-24 11:28:14 +0900 | [diff] [blame] | 781 | #define list_for_each_cookie(pos, head) \ |
| 782 | if (!pos) \ |
| 783 | pos = srcu_dereference((head)->next, &tomoyo_ss); \ |
| 784 | for ( ; pos != (head); pos = srcu_dereference(pos->next, &tomoyo_ss)) |
Tetsuo Handa | fdb8ebb | 2009-12-08 09:34:43 +0900 | [diff] [blame] | 785 | |
Kentaro Takeda | 9590837 | 2009-02-05 17:18:13 +0900 | [diff] [blame] | 786 | #endif /* !defined(_SECURITY_TOMOYO_COMMON_H) */ |