blob: 33d3072f9bb4ab5f2f76f897973d2ff1d5395675 [file] [log] [blame]
Kentaro Takeda95908372009-02-05 17:18:13 +09001/*
2 * security/tomoyo/common.h
3 *
Tetsuo Handa76bb0892010-02-11 09:42:40 +09004 * Header file for TOMOYO.
Kentaro Takeda95908372009-02-05 17:18:13 +09005 *
Tetsuo Handa76bb0892010-02-11 09:42:40 +09006 * Copyright (C) 2005-2010 NTT DATA CORPORATION
Kentaro Takeda95908372009-02-05 17:18:13 +09007 */
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 Handa76bb0892010-02-11 09:42:40 +090022#include <linux/cred.h>
23struct linux_binprm;
Kentaro Takeda95908372009-02-05 17:18:13 +090024
Tetsuo Handa76bb0892010-02-11 09:42:40 +090025/********** Constants definitions. **********/
26
27/*
28 * TOMOYO uses this hash only when appending a string into the string
29 * table. Frequency of appending strings is very low. So we don't need
30 * large (e.g. 64k) hash size. 256 will be sufficient.
31 */
32#define TOMOYO_HASH_BITS 8
33#define TOMOYO_MAX_HASH (1u<<TOMOYO_HASH_BITS)
34
35/*
36 * This is the max length of a token.
37 *
38 * A token consists of only ASCII printable characters.
39 * Non printable characters in a token is represented in \ooo style
40 * octal string. Thus, \ itself is represented as \\.
41 */
42#define TOMOYO_MAX_PATHNAME_LEN 4000
43
44/* Profile number is an integer between 0 and 255. */
45#define TOMOYO_MAX_PROFILES 256
46
47/* Keywords for ACLs. */
48#define TOMOYO_KEYWORD_ALIAS "alias "
49#define TOMOYO_KEYWORD_ALLOW_READ "allow_read "
50#define TOMOYO_KEYWORD_DELETE "delete "
51#define TOMOYO_KEYWORD_DENY_REWRITE "deny_rewrite "
52#define TOMOYO_KEYWORD_FILE_PATTERN "file_pattern "
53#define TOMOYO_KEYWORD_INITIALIZE_DOMAIN "initialize_domain "
54#define TOMOYO_KEYWORD_KEEP_DOMAIN "keep_domain "
55#define TOMOYO_KEYWORD_NO_INITIALIZE_DOMAIN "no_initialize_domain "
56#define TOMOYO_KEYWORD_NO_KEEP_DOMAIN "no_keep_domain "
Tetsuo Handa7762fbf2010-05-10 17:30:26 +090057#define TOMOYO_KEYWORD_PATH_GROUP "path_group "
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +090058#define TOMOYO_KEYWORD_NUMBER_GROUP "number_group "
Tetsuo Handa76bb0892010-02-11 09:42:40 +090059#define TOMOYO_KEYWORD_SELECT "select "
60#define TOMOYO_KEYWORD_USE_PROFILE "use_profile "
61#define TOMOYO_KEYWORD_IGNORE_GLOBAL_ALLOW_READ "ignore_global_allow_read"
62/* A domain definition starts with <kernel>. */
63#define TOMOYO_ROOT_NAME "<kernel>"
64#define TOMOYO_ROOT_NAME_LEN (sizeof(TOMOYO_ROOT_NAME) - 1)
65
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +090066/* Value type definition. */
67#define TOMOYO_VALUE_TYPE_INVALID 0
68#define TOMOYO_VALUE_TYPE_DECIMAL 1
69#define TOMOYO_VALUE_TYPE_OCTAL 2
70#define TOMOYO_VALUE_TYPE_HEXADECIMAL 3
71
Tetsuo Handa76bb0892010-02-11 09:42:40 +090072/* Index numbers for Access Controls. */
Tetsuo Handa084da352010-02-15 15:10:39 +090073enum tomoyo_mac_index {
74 TOMOYO_MAC_FOR_FILE, /* domain_policy.conf */
75 TOMOYO_MAX_ACCEPT_ENTRY,
76 TOMOYO_VERBOSE,
77 TOMOYO_MAX_CONTROL_INDEX
78};
Tetsuo Handa76bb0892010-02-11 09:42:40 +090079
80/* Index numbers for Access Controls. */
Tetsuo Handa084da352010-02-15 15:10:39 +090081enum tomoyo_acl_entry_type_index {
Tetsuo Handa7ef61232010-02-16 08:03:30 +090082 TOMOYO_TYPE_PATH_ACL,
83 TOMOYO_TYPE_PATH2_ACL,
Tetsuo Handa084da352010-02-15 15:10:39 +090084};
Tetsuo Handa76bb0892010-02-11 09:42:40 +090085
86/* Index numbers for File Controls. */
87
88/*
89 * TYPE_READ_WRITE_ACL is special. TYPE_READ_WRITE_ACL is automatically set
90 * if both TYPE_READ_ACL and TYPE_WRITE_ACL are set. Both TYPE_READ_ACL and
91 * TYPE_WRITE_ACL are automatically set if TYPE_READ_WRITE_ACL is set.
92 * TYPE_READ_WRITE_ACL is automatically cleared if either TYPE_READ_ACL or
93 * TYPE_WRITE_ACL is cleared. Both TYPE_READ_ACL and TYPE_WRITE_ACL are
94 * automatically cleared if TYPE_READ_WRITE_ACL is cleared.
95 */
96
Tetsuo Handa084da352010-02-15 15:10:39 +090097enum tomoyo_path_acl_index {
Tetsuo Handa7ef61232010-02-16 08:03:30 +090098 TOMOYO_TYPE_READ_WRITE,
99 TOMOYO_TYPE_EXECUTE,
100 TOMOYO_TYPE_READ,
101 TOMOYO_TYPE_WRITE,
102 TOMOYO_TYPE_CREATE,
103 TOMOYO_TYPE_UNLINK,
104 TOMOYO_TYPE_MKDIR,
105 TOMOYO_TYPE_RMDIR,
106 TOMOYO_TYPE_MKFIFO,
107 TOMOYO_TYPE_MKSOCK,
108 TOMOYO_TYPE_MKBLOCK,
109 TOMOYO_TYPE_MKCHAR,
110 TOMOYO_TYPE_TRUNCATE,
111 TOMOYO_TYPE_SYMLINK,
112 TOMOYO_TYPE_REWRITE,
113 TOMOYO_TYPE_IOCTL,
114 TOMOYO_TYPE_CHMOD,
115 TOMOYO_TYPE_CHOWN,
116 TOMOYO_TYPE_CHGRP,
117 TOMOYO_TYPE_CHROOT,
118 TOMOYO_TYPE_MOUNT,
119 TOMOYO_TYPE_UMOUNT,
120 TOMOYO_MAX_PATH_OPERATION
Tetsuo Handa084da352010-02-15 15:10:39 +0900121};
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900122
Tetsuo Handa084da352010-02-15 15:10:39 +0900123enum tomoyo_path2_acl_index {
Tetsuo Handa7ef61232010-02-16 08:03:30 +0900124 TOMOYO_TYPE_LINK,
125 TOMOYO_TYPE_RENAME,
126 TOMOYO_TYPE_PIVOT_ROOT,
127 TOMOYO_MAX_PATH2_OPERATION
Tetsuo Handa084da352010-02-15 15:10:39 +0900128};
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900129
Tetsuo Handa084da352010-02-15 15:10:39 +0900130enum tomoyo_securityfs_interface_index {
131 TOMOYO_DOMAINPOLICY,
132 TOMOYO_EXCEPTIONPOLICY,
133 TOMOYO_DOMAIN_STATUS,
134 TOMOYO_PROCESS_STATUS,
135 TOMOYO_MEMINFO,
136 TOMOYO_SELFDOMAIN,
137 TOMOYO_VERSION,
138 TOMOYO_PROFILE,
139 TOMOYO_MANAGER
140};
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900141
142/********** Structure definitions. **********/
Kentaro Takeda95908372009-02-05 17:18:13 +0900143
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900144/*
145 * tomoyo_page_buffer is a structure which is used for holding a pathname
146 * obtained from "struct dentry" and "struct vfsmount" pair.
147 * As of now, it is 4096 bytes. If users complain that 4096 bytes is too small
148 * (because TOMOYO escapes non ASCII printable characters using \ooo format),
149 * we will make the buffer larger.
150 */
Kentaro Takeda95908372009-02-05 17:18:13 +0900151struct tomoyo_page_buffer {
152 char buffer[4096];
153};
154
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900155/*
156 * tomoyo_path_info is a structure which is used for holding a string data
157 * used by TOMOYO.
158 * This structure has several fields for supporting pattern matching.
159 *
160 * (1) "name" is the '\0' terminated string data.
161 * (2) "hash" is full_name_hash(name, strlen(name)).
162 * This allows tomoyo_pathcmp() to compare by hash before actually compare
163 * using strcmp().
164 * (3) "const_len" is the length of the initial segment of "name" which
165 * consists entirely of non wildcard characters. In other words, the length
166 * which we can compare two strings using strncmp().
167 * (4) "is_dir" is a bool which is true if "name" ends with "/",
168 * false otherwise.
169 * TOMOYO distinguishes directory and non-directory. A directory ends with
170 * "/" and non-directory does not end with "/".
171 * (5) "is_patterned" is a bool which is true if "name" contains wildcard
172 * characters, false otherwise. This allows TOMOYO to use "hash" and
173 * strcmp() for string comparison if "is_patterned" is false.
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900174 */
Kentaro Takeda95908372009-02-05 17:18:13 +0900175struct tomoyo_path_info {
176 const char *name;
177 u32 hash; /* = full_name_hash(name, strlen(name)) */
Kentaro Takeda95908372009-02-05 17:18:13 +0900178 u16 const_len; /* = tomoyo_const_part_length(name) */
179 bool is_dir; /* = tomoyo_strendswith(name, "/") */
180 bool is_patterned; /* = tomoyo_path_contains_pattern(name) */
Kentaro Takeda95908372009-02-05 17:18:13 +0900181};
182
183/*
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900184 * tomoyo_name_entry is a structure which is used for linking
185 * "struct tomoyo_path_info" into tomoyo_name_list .
Kentaro Takeda95908372009-02-05 17:18:13 +0900186 */
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900187struct tomoyo_name_entry {
188 struct list_head list;
189 atomic_t users;
190 struct tomoyo_path_info entry;
191};
Kentaro Takeda95908372009-02-05 17:18:13 +0900192
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900193/*
194 * tomoyo_path_info_with_data is a structure which is used for holding a
195 * pathname obtained from "struct dentry" and "struct vfsmount" pair.
196 *
197 * "struct tomoyo_path_info_with_data" consists of "struct tomoyo_path_info"
198 * and buffer for the pathname, while "struct tomoyo_page_buffer" consists of
199 * buffer for the pathname only.
200 *
201 * "struct tomoyo_path_info_with_data" is intended to allow TOMOYO to release
202 * both "struct tomoyo_path_info" and buffer for the pathname by single kfree()
203 * so that we don't need to return two pointers to the caller. If the caller
204 * puts "struct tomoyo_path_info" on stack memory, we will be able to remove
205 * "struct tomoyo_path_info_with_data".
206 */
Kentaro Takeda95908372009-02-05 17:18:13 +0900207struct tomoyo_path_info_with_data {
Tetsuo Handa8e2d39a2010-01-26 20:45:27 +0900208 /* Keep "head" first, for this pointer is passed to kfree(). */
Kentaro Takeda95908372009-02-05 17:18:13 +0900209 struct tomoyo_path_info head;
Tetsuo Handaa106cbf2009-03-27 13:12:16 +0900210 char barrier1[16]; /* Safeguard for overrun. */
Kentaro Takeda95908372009-02-05 17:18:13 +0900211 char body[TOMOYO_MAX_PATHNAME_LEN];
212 char barrier2[16]; /* Safeguard for overrun. */
213};
214
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900215struct tomoyo_name_union {
216 const struct tomoyo_path_info *filename;
217 struct tomoyo_path_group *group;
218 u8 is_group;
219};
220
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900221struct tomoyo_number_union {
222 unsigned long values[2];
223 struct tomoyo_number_group *group;
224 u8 min_type;
225 u8 max_type;
226 u8 is_group;
227};
228
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900229/* Structure for "path_group" directive. */
230struct tomoyo_path_group {
231 struct list_head list;
232 const struct tomoyo_path_info *group_name;
233 struct list_head member_list;
234 atomic_t users;
235};
236
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900237/* Structure for "number_group" directive. */
238struct tomoyo_number_group {
239 struct list_head list;
240 const struct tomoyo_path_info *group_name;
241 struct list_head member_list;
242 atomic_t users;
243};
244
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900245/* Structure for "path_group" directive. */
246struct tomoyo_path_group_member {
247 struct list_head list;
248 bool is_deleted;
249 const struct tomoyo_path_info *member_name;
250};
251
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900252/* Structure for "number_group" directive. */
253struct tomoyo_number_group_member {
254 struct list_head list;
255 bool is_deleted;
256 struct tomoyo_number_union number;
257};
258
Kentaro Takeda95908372009-02-05 17:18:13 +0900259/*
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900260 * tomoyo_acl_info is a structure which is used for holding
261 *
262 * (1) "list" which is linked to the ->acl_info_list of
263 * "struct tomoyo_domain_info"
Tetsuo Handaea13ddb2010-02-03 06:43:06 +0900264 * (2) "type" which tells type of the entry (either
Tetsuo Handa7ef61232010-02-16 08:03:30 +0900265 * "struct tomoyo_path_acl" or "struct tomoyo_path2_acl").
Kentaro Takeda95908372009-02-05 17:18:13 +0900266 *
267 * Packing "struct tomoyo_acl_info" allows
Tetsuo Handa7ef61232010-02-16 08:03:30 +0900268 * "struct tomoyo_path_acl" to embed "u8" + "u16" and
269 * "struct tomoyo_path2_acl" to embed "u8"
Kentaro Takeda95908372009-02-05 17:18:13 +0900270 * without enlarging their structure size.
271 */
272struct tomoyo_acl_info {
273 struct list_head list;
Kentaro Takeda95908372009-02-05 17:18:13 +0900274 u8 type;
275} __packed;
276
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900277/*
278 * tomoyo_domain_info is a structure which is used for holding permissions
279 * (e.g. "allow_read /lib/libc-2.5.so") given to each domain.
280 * It has following fields.
281 *
282 * (1) "list" which is linked to tomoyo_domain_list .
283 * (2) "acl_info_list" which is linked to "struct tomoyo_acl_info".
284 * (3) "domainname" which holds the name of the domain.
285 * (4) "profile" which remembers profile number assigned to this domain.
286 * (5) "is_deleted" is a bool which is true if this domain is marked as
287 * "deleted", false otherwise.
288 * (6) "quota_warned" is a bool which is used for suppressing warning message
289 * when learning mode learned too much entries.
Tetsuo Handaea13ddb2010-02-03 06:43:06 +0900290 * (7) "ignore_global_allow_read" is a bool which is true if this domain
291 * should ignore "allow_read" directive in exception policy.
292 * (8) "transition_failed" is a bool which is set to true when this domain was
293 * unable to create a new domain at tomoyo_find_next_domain() because the
294 * name of the domain to be created was too long or it could not allocate
295 * memory. If set to true, more than one process continued execve()
296 * without domain transition.
Tetsuo Handaec8e6a42010-02-11 09:43:20 +0900297 * (9) "users" is an atomic_t that holds how many "struct cred"->security
298 * are referring this "struct tomoyo_domain_info". If is_deleted == true
299 * and users == 0, this struct will be kfree()d upon next garbage
300 * collection.
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900301 *
302 * A domain's lifecycle is an analogy of files on / directory.
303 * Multiple domains with the same domainname cannot be created (as with
304 * creating files with the same filename fails with -EEXIST).
305 * If a process reached a domain, that process can reside in that domain after
306 * that domain is marked as "deleted" (as with a process can access an already
307 * open()ed file after that file was unlink()ed).
308 */
Kentaro Takeda95908372009-02-05 17:18:13 +0900309struct tomoyo_domain_info {
310 struct list_head list;
311 struct list_head acl_info_list;
312 /* Name of this domain. Never NULL. */
313 const struct tomoyo_path_info *domainname;
314 u8 profile; /* Profile number to use. */
Tetsuo Handaa0558fc2009-04-06 20:49:14 +0900315 bool is_deleted; /* Delete flag. */
Kentaro Takeda95908372009-02-05 17:18:13 +0900316 bool quota_warned; /* Quota warnning flag. */
Tetsuo Handaea13ddb2010-02-03 06:43:06 +0900317 bool ignore_global_allow_read; /* Ignore "allow_read" flag. */
318 bool transition_failed; /* Domain transition failed flag. */
Tetsuo Handaec8e6a42010-02-11 09:43:20 +0900319 atomic_t users; /* Number of referring credentials. */
Kentaro Takeda95908372009-02-05 17:18:13 +0900320};
321
Kentaro Takeda95908372009-02-05 17:18:13 +0900322/*
Tetsuo Handa7ef61232010-02-16 08:03:30 +0900323 * tomoyo_path_acl is a structure which is used for holding an
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900324 * entry with one pathname operation (e.g. open(), mkdir()).
325 * It has following fields.
326 *
327 * (1) "head" which is a "struct tomoyo_acl_info".
328 * (2) "perm" which is a bitmask of permitted operations.
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900329 * (3) "name" is the pathname.
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900330 *
331 * Directives held by this structure are "allow_read/write", "allow_execute",
332 * "allow_read", "allow_write", "allow_create", "allow_unlink", "allow_mkdir",
333 * "allow_rmdir", "allow_mkfifo", "allow_mksock", "allow_mkblock",
Tetsuo Handa937bf612009-12-02 21:09:48 +0900334 * "allow_mkchar", "allow_truncate", "allow_symlink", "allow_rewrite",
335 * "allow_chmod", "allow_chown", "allow_chgrp", "allow_chroot", "allow_mount"
336 * and "allow_unmount".
Kentaro Takeda95908372009-02-05 17:18:13 +0900337 */
Tetsuo Handa7ef61232010-02-16 08:03:30 +0900338struct tomoyo_path_acl {
339 struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH_ACL */
Tetsuo Handa937bf612009-12-02 21:09:48 +0900340 u8 perm_high;
Kentaro Takeda95908372009-02-05 17:18:13 +0900341 u16 perm;
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900342 struct tomoyo_name_union name;
Kentaro Takeda95908372009-02-05 17:18:13 +0900343};
344
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900345/*
Tetsuo Handa7ef61232010-02-16 08:03:30 +0900346 * tomoyo_path2_acl is a structure which is used for holding an
Tetsuo Handa937bf612009-12-02 21:09:48 +0900347 * entry with two pathnames operation (i.e. link(), rename() and pivot_root()).
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900348 * It has following fields.
349 *
350 * (1) "head" which is a "struct tomoyo_acl_info".
351 * (2) "perm" which is a bitmask of permitted operations.
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900352 * (3) "name1" is the source/old pathname.
353 * (4) "name2" is the destination/new pathname.
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900354 *
Tetsuo Handa937bf612009-12-02 21:09:48 +0900355 * Directives held by this structure are "allow_rename", "allow_link" and
356 * "allow_pivot_root".
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900357 */
Tetsuo Handa7ef61232010-02-16 08:03:30 +0900358struct tomoyo_path2_acl {
359 struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH2_ACL */
Kentaro Takeda95908372009-02-05 17:18:13 +0900360 u8 perm;
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900361 struct tomoyo_name_union name1;
362 struct tomoyo_name_union name2;
Kentaro Takeda95908372009-02-05 17:18:13 +0900363};
364
Tetsuo Handac3fa1092009-06-08 12:37:39 +0900365/*
366 * tomoyo_io_buffer is a structure which is used for reading and modifying
367 * configuration via /sys/kernel/security/tomoyo/ interface.
368 * It has many fields. ->read_var1 , ->read_var2 , ->write_var1 are used as
369 * cursors.
370 *
371 * Since the content of /sys/kernel/security/tomoyo/domain_policy is a list of
372 * "struct tomoyo_domain_info" entries and each "struct tomoyo_domain_info"
373 * entry has a list of "struct tomoyo_acl_info", we need two cursors when
374 * reading (one is for traversing tomoyo_domain_list and the other is for
375 * traversing "struct tomoyo_acl_info"->acl_info_list ).
376 *
377 * If a line written to /sys/kernel/security/tomoyo/domain_policy starts with
378 * "select ", TOMOYO seeks the cursor ->read_var1 and ->write_var1 to the
379 * domain with the domainname specified by the rest of that line (NULL is set
380 * if seek failed).
381 * If a line written to /sys/kernel/security/tomoyo/domain_policy starts with
382 * "delete ", TOMOYO deletes an entry or a domain specified by the rest of that
383 * line (->write_var1 is set to NULL if a domain was deleted).
384 * If a line written to /sys/kernel/security/tomoyo/domain_policy starts with
385 * neither "select " nor "delete ", an entry or a domain specified by that line
386 * is appended.
387 */
Kentaro Takeda95908372009-02-05 17:18:13 +0900388struct tomoyo_io_buffer {
389 int (*read) (struct tomoyo_io_buffer *);
390 int (*write) (struct tomoyo_io_buffer *);
391 /* Exclusive lock for this structure. */
392 struct mutex io_sem;
Tetsuo Handafdb8ebb2009-12-08 09:34:43 +0900393 /* Index returned by tomoyo_read_lock(). */
394 int reader_idx;
Kentaro Takeda95908372009-02-05 17:18:13 +0900395 /* The position currently reading from. */
396 struct list_head *read_var1;
397 /* Extra variables for reading. */
398 struct list_head *read_var2;
399 /* The position currently writing to. */
400 struct tomoyo_domain_info *write_var1;
401 /* The step for reading. */
402 int read_step;
403 /* Buffer for reading. */
404 char *read_buf;
405 /* EOF flag for reading. */
406 bool read_eof;
407 /* Read domain ACL of specified PID? */
408 bool read_single_domain;
409 /* Extra variable for reading. */
410 u8 read_bit;
411 /* Bytes available for reading. */
412 int read_avail;
413 /* Size of read buffer. */
414 int readbuf_size;
415 /* Buffer for writing. */
416 char *write_buf;
417 /* Bytes available for writing. */
418 int write_avail;
419 /* Size of write buffer. */
420 int writebuf_size;
421};
422
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900423/*
424 * tomoyo_globally_readable_file_entry is a structure which is used for holding
425 * "allow_read" entries.
426 * It has following fields.
427 *
428 * (1) "list" which is linked to tomoyo_globally_readable_list .
429 * (2) "filename" is a pathname which is allowed to open(O_RDONLY).
430 * (3) "is_deleted" is a bool which is true if marked as deleted, false
431 * otherwise.
432 */
433struct tomoyo_globally_readable_file_entry {
434 struct list_head list;
435 const struct tomoyo_path_info *filename;
436 bool is_deleted;
437};
438
439/*
440 * tomoyo_pattern_entry is a structure which is used for holding
441 * "tomoyo_pattern_list" entries.
442 * It has following fields.
443 *
444 * (1) "list" which is linked to tomoyo_pattern_list .
445 * (2) "pattern" is a pathname pattern which is used for converting pathnames
446 * to pathname patterns during learning mode.
447 * (3) "is_deleted" is a bool which is true if marked as deleted, false
448 * otherwise.
449 */
450struct tomoyo_pattern_entry {
451 struct list_head list;
452 const struct tomoyo_path_info *pattern;
453 bool is_deleted;
454};
455
456/*
457 * tomoyo_no_rewrite_entry is a structure which is used for holding
458 * "deny_rewrite" entries.
459 * It has following fields.
460 *
461 * (1) "list" which is linked to tomoyo_no_rewrite_list .
462 * (2) "pattern" is a pathname which is by default not permitted to modify
463 * already existing content.
464 * (3) "is_deleted" is a bool which is true if marked as deleted, false
465 * otherwise.
466 */
467struct tomoyo_no_rewrite_entry {
468 struct list_head list;
469 const struct tomoyo_path_info *pattern;
470 bool is_deleted;
471};
472
473/*
474 * tomoyo_domain_initializer_entry is a structure which is used for holding
475 * "initialize_domain" and "no_initialize_domain" entries.
476 * It has following fields.
477 *
478 * (1) "list" which is linked to tomoyo_domain_initializer_list .
479 * (2) "domainname" which is "a domainname" or "the last component of a
480 * domainname". This field is NULL if "from" clause is not specified.
481 * (3) "program" which is a program's pathname.
482 * (4) "is_deleted" is a bool which is true if marked as deleted, false
483 * otherwise.
484 * (5) "is_not" is a bool which is true if "no_initialize_domain", false
485 * otherwise.
486 * (6) "is_last_name" is a bool which is true if "domainname" is "the last
487 * component of a domainname", false otherwise.
488 */
489struct tomoyo_domain_initializer_entry {
490 struct list_head list;
491 const struct tomoyo_path_info *domainname; /* This may be NULL */
492 const struct tomoyo_path_info *program;
493 bool is_deleted;
494 bool is_not; /* True if this entry is "no_initialize_domain". */
495 /* True if the domainname is tomoyo_get_last_name(). */
496 bool is_last_name;
497};
498
499/*
500 * tomoyo_domain_keeper_entry is a structure which is used for holding
501 * "keep_domain" and "no_keep_domain" entries.
502 * It has following fields.
503 *
504 * (1) "list" which is linked to tomoyo_domain_keeper_list .
505 * (2) "domainname" which is "a domainname" or "the last component of a
506 * domainname".
507 * (3) "program" which is a program's pathname.
508 * This field is NULL if "from" clause is not specified.
509 * (4) "is_deleted" is a bool which is true if marked as deleted, false
510 * otherwise.
511 * (5) "is_not" is a bool which is true if "no_initialize_domain", false
512 * otherwise.
513 * (6) "is_last_name" is a bool which is true if "domainname" is "the last
514 * component of a domainname", false otherwise.
515 */
516struct tomoyo_domain_keeper_entry {
517 struct list_head list;
518 const struct tomoyo_path_info *domainname;
519 const struct tomoyo_path_info *program; /* This may be NULL */
520 bool is_deleted;
521 bool is_not; /* True if this entry is "no_keep_domain". */
522 /* True if the domainname is tomoyo_get_last_name(). */
523 bool is_last_name;
524};
525
526/*
527 * tomoyo_alias_entry is a structure which is used for holding "alias" entries.
528 * It has following fields.
529 *
530 * (1) "list" which is linked to tomoyo_alias_list .
531 * (2) "original_name" which is a dereferenced pathname.
532 * (3) "aliased_name" which is a symlink's pathname.
533 * (4) "is_deleted" is a bool which is true if marked as deleted, false
534 * otherwise.
535 */
536struct tomoyo_alias_entry {
537 struct list_head list;
538 const struct tomoyo_path_info *original_name;
539 const struct tomoyo_path_info *aliased_name;
540 bool is_deleted;
541};
542
543/*
544 * tomoyo_policy_manager_entry is a structure which is used for holding list of
545 * domainnames or programs which are permitted to modify configuration via
546 * /sys/kernel/security/tomoyo/ interface.
547 * It has following fields.
548 *
549 * (1) "list" which is linked to tomoyo_policy_manager_list .
550 * (2) "manager" is a domainname or a program's pathname.
551 * (3) "is_domain" is a bool which is true if "manager" is a domainname, false
552 * otherwise.
553 * (4) "is_deleted" is a bool which is true if marked as deleted, false
554 * otherwise.
555 */
556struct tomoyo_policy_manager_entry {
557 struct list_head list;
558 /* A path to program or a domainname. */
559 const struct tomoyo_path_info *manager;
560 bool is_domain; /* True if manager is a domainname. */
561 bool is_deleted; /* True if this entry is deleted. */
562};
563
564/********** Function prototypes. **********/
565
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900566/* Check whether the given name matches the given name_union. */
567bool tomoyo_compare_name_union(const struct tomoyo_path_info *name,
568 const struct tomoyo_name_union *ptr);
Kentaro Takeda95908372009-02-05 17:18:13 +0900569/* Check whether the domain has too many ACL entries to hold. */
570bool tomoyo_domain_quota_is_ok(struct tomoyo_domain_info * const domain);
571/* Transactional sprintf() for policy dump. */
572bool tomoyo_io_printf(struct tomoyo_io_buffer *head, const char *fmt, ...)
573 __attribute__ ((format(printf, 2, 3)));
574/* Check whether the domainname is correct. */
Tetsuo Handa17080002010-02-16 21:14:48 +0900575bool tomoyo_is_correct_domain(const unsigned char *domainname);
Kentaro Takeda95908372009-02-05 17:18:13 +0900576/* Check whether the token is correct. */
577bool tomoyo_is_correct_path(const char *filename, const s8 start_type,
Tetsuo Handa17080002010-02-16 21:14:48 +0900578 const s8 pattern_type, const s8 end_type);
Kentaro Takeda95908372009-02-05 17:18:13 +0900579/* Check whether the token can be a domainname. */
580bool tomoyo_is_domain_def(const unsigned char *buffer);
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900581bool tomoyo_parse_name_union(const char *filename,
582 struct tomoyo_name_union *ptr);
583/* Check whether the given filename matches the given path_group. */
584bool tomoyo_path_matches_group(const struct tomoyo_path_info *pathname,
585 const struct tomoyo_path_group *group,
586 const bool may_use_pattern);
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900587/* Check whether the given value matches the given number_group. */
588bool tomoyo_number_matches_group(const unsigned long min,
589 const unsigned long max,
590 const struct tomoyo_number_group *group);
Kentaro Takeda95908372009-02-05 17:18:13 +0900591/* Check whether the given filename matches the given pattern. */
592bool tomoyo_path_matches_pattern(const struct tomoyo_path_info *filename,
593 const struct tomoyo_path_info *pattern);
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900594
595bool tomoyo_print_number_union(struct tomoyo_io_buffer *head,
596 const struct tomoyo_number_union *ptr);
597bool tomoyo_parse_number_union(char *data, struct tomoyo_number_union *num);
598
Kentaro Takeda95908372009-02-05 17:18:13 +0900599/* Read "alias" entry in exception policy. */
600bool tomoyo_read_alias_policy(struct tomoyo_io_buffer *head);
601/*
602 * Read "initialize_domain" and "no_initialize_domain" entry
603 * in exception policy.
604 */
605bool tomoyo_read_domain_initializer_policy(struct tomoyo_io_buffer *head);
606/* Read "keep_domain" and "no_keep_domain" entry in exception policy. */
607bool tomoyo_read_domain_keeper_policy(struct tomoyo_io_buffer *head);
608/* Read "file_pattern" entry in exception policy. */
609bool tomoyo_read_file_pattern(struct tomoyo_io_buffer *head);
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900610/* Read "path_group" entry in exception policy. */
611bool tomoyo_read_path_group_policy(struct tomoyo_io_buffer *head);
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900612/* Read "number_group" entry in exception policy. */
613bool tomoyo_read_number_group_policy(struct tomoyo_io_buffer *head);
Kentaro Takeda95908372009-02-05 17:18:13 +0900614/* Read "allow_read" entry in exception policy. */
615bool tomoyo_read_globally_readable_policy(struct tomoyo_io_buffer *head);
616/* Read "deny_rewrite" entry in exception policy. */
617bool tomoyo_read_no_rewrite_policy(struct tomoyo_io_buffer *head);
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900618/* Tokenize a line. */
619bool tomoyo_tokenize(char *buffer, char *w[], size_t size);
Kentaro Takeda95908372009-02-05 17:18:13 +0900620/* Write domain policy violation warning message to console? */
621bool tomoyo_verbose_mode(const struct tomoyo_domain_info *domain);
622/* Convert double path operation to operation name. */
Tetsuo Handa7ef61232010-02-16 08:03:30 +0900623const char *tomoyo_path22keyword(const u8 operation);
Kentaro Takeda95908372009-02-05 17:18:13 +0900624/* Get the last component of the given domainname. */
625const char *tomoyo_get_last_name(const struct tomoyo_domain_info *domain);
626/* Get warning message. */
627const char *tomoyo_get_msg(const bool is_enforce);
628/* Convert single path operation to operation name. */
Tetsuo Handa7ef61232010-02-16 08:03:30 +0900629const char *tomoyo_path2keyword(const u8 operation);
Kentaro Takeda95908372009-02-05 17:18:13 +0900630/* Create "alias" entry in exception policy. */
631int tomoyo_write_alias_policy(char *data, const bool is_delete);
632/*
633 * Create "initialize_domain" and "no_initialize_domain" entry
634 * in exception policy.
635 */
636int tomoyo_write_domain_initializer_policy(char *data, const bool is_not,
637 const bool is_delete);
638/* Create "keep_domain" and "no_keep_domain" entry in exception policy. */
639int tomoyo_write_domain_keeper_policy(char *data, const bool is_not,
640 const bool is_delete);
641/*
642 * Create "allow_read/write", "allow_execute", "allow_read", "allow_write",
643 * "allow_create", "allow_unlink", "allow_mkdir", "allow_rmdir",
644 * "allow_mkfifo", "allow_mksock", "allow_mkblock", "allow_mkchar",
645 * "allow_truncate", "allow_symlink", "allow_rewrite", "allow_rename" and
646 * "allow_link" entry in domain policy.
647 */
648int tomoyo_write_file_policy(char *data, struct tomoyo_domain_info *domain,
649 const bool is_delete);
650/* Create "allow_read" entry in exception policy. */
651int tomoyo_write_globally_readable_policy(char *data, const bool is_delete);
652/* Create "deny_rewrite" entry in exception policy. */
653int tomoyo_write_no_rewrite_policy(char *data, const bool is_delete);
654/* Create "file_pattern" entry in exception policy. */
655int tomoyo_write_pattern_policy(char *data, const bool is_delete);
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900656/* Create "path_group" entry in exception policy. */
657int tomoyo_write_path_group_policy(char *data, const bool is_delete);
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900658/* Create "number_group" entry in exception policy. */
659int tomoyo_write_number_group_policy(char *data, const bool is_delete);
Kentaro Takeda95908372009-02-05 17:18:13 +0900660/* Find a domain by the given name. */
661struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname);
662/* Find or create a domain by the given name. */
663struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char *
664 domainname,
665 const u8 profile);
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900666
667/* Allocate memory for "struct tomoyo_path_group". */
668struct tomoyo_path_group *tomoyo_get_path_group(const char *group_name);
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900669struct tomoyo_number_group *tomoyo_get_number_group(const char *group_name);
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900670
Kentaro Takeda95908372009-02-05 17:18:13 +0900671/* Check mode for specified functionality. */
672unsigned int tomoyo_check_flags(const struct tomoyo_domain_info *domain,
673 const u8 index);
Kentaro Takeda95908372009-02-05 17:18:13 +0900674/* Fill in "struct tomoyo_path_info" members. */
675void tomoyo_fill_path_info(struct tomoyo_path_info *ptr);
676/* Run policy loader when /sbin/init starts. */
677void tomoyo_load_policy(const char *filename);
Kentaro Takeda95908372009-02-05 17:18:13 +0900678
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900679void tomoyo_put_number_union(struct tomoyo_number_union *ptr);
680
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900681/* Convert binary string to ascii string. */
682int tomoyo_encode(char *buffer, int buflen, const char *str);
683
684/* Returns realpath(3) of the given pathname but ignores chroot'ed root. */
685int tomoyo_realpath_from_path2(struct path *path, char *newname,
686 int newname_len);
687
688/*
689 * Returns realpath(3) of the given pathname but ignores chroot'ed root.
690 * These functions use kzalloc(), so the caller must call kfree()
691 * if these functions didn't return NULL.
692 */
693char *tomoyo_realpath(const char *pathname);
694/*
695 * Same with tomoyo_realpath() except that it doesn't follow the final symlink.
696 */
697char *tomoyo_realpath_nofollow(const char *pathname);
698/* Same with tomoyo_realpath() except that the pathname is already solved. */
699char *tomoyo_realpath_from_path(struct path *path);
700
701/* Check memory quota. */
702bool tomoyo_memory_ok(void *ptr);
Tetsuo Handa9e4b50e2010-05-06 12:40:02 +0900703void *tomoyo_commit_ok(void *data, const unsigned int size);
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900704
705/*
706 * Keep the given name on the RAM.
707 * The RAM is shared, so NEVER try to modify or kfree() the returned name.
708 */
709const struct tomoyo_path_info *tomoyo_get_name(const char *name);
710
711/* Check for memory usage. */
712int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head);
713
714/* Set memory quota. */
715int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head);
716
717/* Initialize realpath related code. */
718void __init tomoyo_realpath_init(void);
719int tomoyo_check_exec_perm(struct tomoyo_domain_info *domain,
720 const struct tomoyo_path_info *filename);
721int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
722 struct path *path, const int flag);
Tetsuo Handa97d69312010-02-16 09:46:15 +0900723int tomoyo_path_perm(const u8 operation, struct path *path);
724int tomoyo_path2_perm(const u8 operation, struct path *path1,
725 struct path *path2);
726int tomoyo_check_rewrite_permission(struct file *filp);
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900727int tomoyo_find_next_domain(struct linux_binprm *bprm);
728
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900729/* Drop refcount on tomoyo_name_union. */
730void tomoyo_put_name_union(struct tomoyo_name_union *ptr);
731
Tetsuo Handa847b1732010-02-11 09:43:54 +0900732/* Run garbage collector. */
733void tomoyo_run_gc(void);
734
735void tomoyo_memory_free(void *ptr);
736
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900737/********** External variable definitions. **********/
738
739/* Lock for GC. */
740extern struct srcu_struct tomoyo_ss;
741
742/* The list for "struct tomoyo_domain_info". */
743extern struct list_head tomoyo_domain_list;
744
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900745extern struct list_head tomoyo_path_group_list;
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900746extern struct list_head tomoyo_number_group_list;
Tetsuo Handa847b1732010-02-11 09:43:54 +0900747extern struct list_head tomoyo_domain_initializer_list;
748extern struct list_head tomoyo_domain_keeper_list;
749extern struct list_head tomoyo_alias_list;
750extern struct list_head tomoyo_globally_readable_list;
751extern struct list_head tomoyo_pattern_list;
752extern struct list_head tomoyo_no_rewrite_list;
753extern struct list_head tomoyo_policy_manager_list;
754extern struct list_head tomoyo_name_list[TOMOYO_MAX_HASH];
Tetsuo Handa847b1732010-02-11 09:43:54 +0900755
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900756/* Lock for protecting policy. */
757extern struct mutex tomoyo_policy_lock;
758
759/* Has /sbin/init started? */
760extern bool tomoyo_policy_loaded;
761
762/* The kernel's domain. */
763extern struct tomoyo_domain_info tomoyo_kernel_domain;
764
765/********** Inlined functions. **********/
766
767static inline int tomoyo_read_lock(void)
768{
769 return srcu_read_lock(&tomoyo_ss);
770}
771
772static inline void tomoyo_read_unlock(int idx)
773{
774 srcu_read_unlock(&tomoyo_ss, idx);
775}
776
Kentaro Takeda95908372009-02-05 17:18:13 +0900777/* strcmp() for "struct tomoyo_path_info" structure. */
778static inline bool tomoyo_pathcmp(const struct tomoyo_path_info *a,
779 const struct tomoyo_path_info *b)
780{
781 return a->hash != b->hash || strcmp(a->name, b->name);
782}
783
Kentaro Takeda95908372009-02-05 17:18:13 +0900784/**
785 * tomoyo_is_valid - Check whether the character is a valid char.
786 *
787 * @c: The character to check.
788 *
789 * Returns true if @c is a valid character, false otherwise.
790 */
791static inline bool tomoyo_is_valid(const unsigned char c)
792{
793 return c > ' ' && c < 127;
794}
795
796/**
797 * tomoyo_is_invalid - Check whether the character is an invalid char.
798 *
799 * @c: The character to check.
800 *
801 * Returns true if @c is an invalid character, false otherwise.
802 */
803static inline bool tomoyo_is_invalid(const unsigned char c)
804{
805 return c && (c <= ' ' || c >= 127);
806}
807
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900808static inline void tomoyo_put_name(const struct tomoyo_path_info *name)
809{
810 if (name) {
811 struct tomoyo_name_entry *ptr =
812 container_of(name, struct tomoyo_name_entry, entry);
813 atomic_dec(&ptr->users);
814 }
815}
Kentaro Takeda95908372009-02-05 17:18:13 +0900816
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900817static inline void tomoyo_put_path_group(struct tomoyo_path_group *group)
818{
819 if (group)
820 atomic_dec(&group->users);
821}
822
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900823static inline void tomoyo_put_number_group(struct tomoyo_number_group *group)
824{
825 if (group)
826 atomic_dec(&group->users);
827}
828
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900829static inline struct tomoyo_domain_info *tomoyo_domain(void)
830{
831 return current_cred()->security;
832}
Kentaro Takeda95908372009-02-05 17:18:13 +0900833
Tetsuo Handa76bb0892010-02-11 09:42:40 +0900834static inline struct tomoyo_domain_info *tomoyo_real_domain(struct task_struct
835 *task)
836{
837 return task_cred_xxx(task, security);
838}
Kentaro Takeda95908372009-02-05 17:18:13 +0900839
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900840static inline bool tomoyo_is_same_acl_head(const struct tomoyo_acl_info *p1,
841 const struct tomoyo_acl_info *p2)
842{
843 return p1->type == p2->type;
844}
845
846static inline bool tomoyo_is_same_name_union
847(const struct tomoyo_name_union *p1, const struct tomoyo_name_union *p2)
848{
849 return p1->filename == p2->filename && p1->group == p2->group &&
850 p1->is_group == p2->is_group;
851}
852
Tetsuo Handa4c3e9e22010-05-17 10:06:58 +0900853static inline bool tomoyo_is_same_number_union
854(const struct tomoyo_number_union *p1, const struct tomoyo_number_union *p2)
855{
856 return p1->values[0] == p2->values[0] && p1->values[1] == p2->values[1]
857 && p1->group == p2->group && p1->min_type == p2->min_type &&
858 p1->max_type == p2->max_type && p1->is_group == p2->is_group;
859}
860
Tetsuo Handa7762fbf2010-05-10 17:30:26 +0900861static inline bool tomoyo_is_same_path_acl(const struct tomoyo_path_acl *p1,
862 const struct tomoyo_path_acl *p2)
863{
864 return tomoyo_is_same_acl_head(&p1->head, &p2->head) &&
865 tomoyo_is_same_name_union(&p1->name, &p2->name);
866}
867
868static inline bool tomoyo_is_same_path2_acl(const struct tomoyo_path2_acl *p1,
869 const struct tomoyo_path2_acl *p2)
870{
871 return tomoyo_is_same_acl_head(&p1->head, &p2->head) &&
872 tomoyo_is_same_name_union(&p1->name1, &p2->name1) &&
873 tomoyo_is_same_name_union(&p1->name2, &p2->name2);
874}
875
Tetsuo Handa9e4b50e2010-05-06 12:40:02 +0900876static inline bool tomoyo_is_same_domain_initializer_entry
877(const struct tomoyo_domain_initializer_entry *p1,
878 const struct tomoyo_domain_initializer_entry *p2)
879{
880 return p1->is_not == p2->is_not && p1->is_last_name == p2->is_last_name
881 && p1->domainname == p2->domainname
882 && p1->program == p2->program;
883}
884
885static inline bool tomoyo_is_same_domain_keeper_entry
886(const struct tomoyo_domain_keeper_entry *p1,
887 const struct tomoyo_domain_keeper_entry *p2)
888{
889 return p1->is_not == p2->is_not && p1->is_last_name == p2->is_last_name
890 && p1->domainname == p2->domainname
891 && p1->program == p2->program;
892}
893
894static inline bool tomoyo_is_same_alias_entry
895(const struct tomoyo_alias_entry *p1, const struct tomoyo_alias_entry *p2)
896{
897 return p1->original_name == p2->original_name &&
898 p1->aliased_name == p2->aliased_name;
899}
900
Kentaro Takeda95908372009-02-05 17:18:13 +0900901/**
902 * list_for_each_cookie - iterate over a list with cookie.
903 * @pos: the &struct list_head to use as a loop cursor.
904 * @cookie: the &struct list_head to use as a cookie.
905 * @head: the head for your list.
906 *
Tetsuo Handafdb8ebb2009-12-08 09:34:43 +0900907 * Same with list_for_each_rcu() except that this primitive uses @cookie
Kentaro Takeda95908372009-02-05 17:18:13 +0900908 * so that we can continue iteration.
909 * @cookie must be NULL when iteration starts, and @cookie will become
910 * NULL when iteration finishes.
911 */
Tetsuo Handafdb8ebb2009-12-08 09:34:43 +0900912#define list_for_each_cookie(pos, cookie, head) \
913 for (({ if (!cookie) \
914 cookie = head; }), \
915 pos = rcu_dereference((cookie)->next); \
916 prefetch(pos->next), pos != (head) || ((cookie) = NULL); \
917 (cookie) = pos, pos = rcu_dereference(pos->next))
918
Kentaro Takeda95908372009-02-05 17:18:13 +0900919#endif /* !defined(_SECURITY_TOMOYO_COMMON_H) */