/* * TOMOYO uses this hash only when appending a string into the string * table. Frequency of appending strings is very low. So we don't need * large (e.g. 64k) hash size. 256 will be sufficient.
*/ #define TOMOYO_HASH_BITS 8 #define TOMOYO_MAX_HASH (1u<<TOMOYO_HASH_BITS)
/* * TOMOYO checks only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET. * Therefore, we don't need SOCK_MAX.
*/ #define TOMOYO_SOCK_MAX 6
#define TOMOYO_EXEC_TMPSIZE 4096
/* Garbage collector is trying to kfree() this element. */ #define TOMOYO_GC_IN_PROGRESS -1
/* Profile number is an integer between 0 and 255. */ #define TOMOYO_MAX_PROFILES 256
/* Group number is an integer between 0 and 255. */ #define TOMOYO_MAX_ACL_GROUPS 256
/* Index numbers for stat(). */ enum tomoyo_path_stat_index { /* Do not change this order. */
TOMOYO_PATH1,
TOMOYO_PATH1_PARENT,
TOMOYO_PATH2,
TOMOYO_PATH2_PARENT,
TOMOYO_MAX_PATH_STAT
};
/* Index numbers for domain's attributes. */ enum tomoyo_domain_info_flags_index { /* Quota warnning flag. */
TOMOYO_DIF_QUOTA_WARNED, /* * This domain was unable to create a new domain at * tomoyo_find_next_domain() because the name of the domain to be * created was too long or it could not allocate memory. * More than one process continued execve() without domain transition.
*/
TOMOYO_DIF_TRANSITION_FAILED,
TOMOYO_MAX_DOMAIN_INFO_FLAGS
};
/* Index numbers for audit type. */ enum tomoyo_grant_log { /* Follow profile's configuration. */
TOMOYO_GRANTLOG_AUTO, /* Do not generate grant log. */
TOMOYO_GRANTLOG_NO, /* Generate grant_log. */
TOMOYO_GRANTLOG_YES,
};
/* Index numbers for group entries. */ enum tomoyo_group_id {
TOMOYO_PATH_GROUP,
TOMOYO_NUMBER_GROUP,
TOMOYO_ADDRESS_GROUP,
TOMOYO_MAX_GROUP
};
/* Index numbers for type of numeric values. */ enum tomoyo_value_type {
TOMOYO_VALUE_TYPE_INVALID,
TOMOYO_VALUE_TYPE_DECIMAL,
TOMOYO_VALUE_TYPE_OCTAL,
TOMOYO_VALUE_TYPE_HEXADECIMAL,
};
/* Index numbers for domain transition control keywords. */ enum tomoyo_transition_type { /* Do not change this order, */
TOMOYO_TRANSITION_CONTROL_NO_RESET,
TOMOYO_TRANSITION_CONTROL_RESET,
TOMOYO_TRANSITION_CONTROL_NO_INITIALIZE,
TOMOYO_TRANSITION_CONTROL_INITIALIZE,
TOMOYO_TRANSITION_CONTROL_NO_KEEP,
TOMOYO_TRANSITION_CONTROL_KEEP,
TOMOYO_MAX_TRANSITION_TYPE
};
/* Index numbers for Access Controls. */ enum tomoyo_acl_entry_type_index {
TOMOYO_TYPE_PATH_ACL,
TOMOYO_TYPE_PATH2_ACL,
TOMOYO_TYPE_PATH_NUMBER_ACL,
TOMOYO_TYPE_MKDEV_ACL,
TOMOYO_TYPE_MOUNT_ACL,
TOMOYO_TYPE_INET_ACL,
TOMOYO_TYPE_UNIX_ACL,
TOMOYO_TYPE_ENV_ACL,
TOMOYO_TYPE_MANUAL_TASK_ACL,
};
/* Index numbers for access controls with one pathname. */ enum tomoyo_path_acl_index {
TOMOYO_TYPE_EXECUTE,
TOMOYO_TYPE_READ,
TOMOYO_TYPE_WRITE,
TOMOYO_TYPE_APPEND,
TOMOYO_TYPE_UNLINK,
TOMOYO_TYPE_GETATTR,
TOMOYO_TYPE_RMDIR,
TOMOYO_TYPE_TRUNCATE,
TOMOYO_TYPE_SYMLINK,
TOMOYO_TYPE_CHROOT,
TOMOYO_TYPE_UMOUNT,
TOMOYO_MAX_PATH_OPERATION
};
/* Index numbers for /sys/kernel/security/tomoyo/stat interface. */ enum tomoyo_memory_stat_type {
TOMOYO_MEMORY_POLICY,
TOMOYO_MEMORY_AUDIT,
TOMOYO_MEMORY_QUERY,
TOMOYO_MAX_MEMORY_STAT
};
/* Index numbers for access controls with two pathnames. */ enum tomoyo_path2_acl_index {
TOMOYO_TYPE_LINK,
TOMOYO_TYPE_RENAME,
TOMOYO_TYPE_PIVOT_ROOT,
TOMOYO_MAX_PATH2_OPERATION
};
/* Index numbers for access controls with one pathname and one number. */ enum tomoyo_path_number_acl_index {
TOMOYO_TYPE_CREATE,
TOMOYO_TYPE_MKDIR,
TOMOYO_TYPE_MKFIFO,
TOMOYO_TYPE_MKSOCK,
TOMOYO_TYPE_IOCTL,
TOMOYO_TYPE_CHMOD,
TOMOYO_TYPE_CHOWN,
TOMOYO_TYPE_CHGRP,
TOMOYO_MAX_PATH_NUMBER_OPERATION
};
/* Index numbers for /sys/kernel/security/tomoyo/ interfaces. */ enum tomoyo_securityfs_interface_index {
TOMOYO_DOMAINPOLICY,
TOMOYO_EXCEPTIONPOLICY,
TOMOYO_PROCESS_STATUS,
TOMOYO_STAT,
TOMOYO_AUDIT,
TOMOYO_VERSION,
TOMOYO_PROFILE,
TOMOYO_QUERY,
TOMOYO_MANAGER
};
/* Index numbers for special mount operations. */ enum tomoyo_special_mount {
TOMOYO_MOUNT_BIND, /* mount --bind /source /dest */
TOMOYO_MOUNT_MOVE, /* mount --move /old /new */
TOMOYO_MOUNT_REMOUNT, /* mount -o remount /dir */
TOMOYO_MOUNT_MAKE_UNBINDABLE, /* mount --make-unbindable /dir */
TOMOYO_MOUNT_MAKE_PRIVATE, /* mount --make-private /dir */
TOMOYO_MOUNT_MAKE_SLAVE, /* mount --make-slave /dir */
TOMOYO_MOUNT_MAKE_SHARED, /* mount --make-shared /dir */
TOMOYO_MAX_SPECIAL_MOUNT
};
/* Index numbers for category of functionality. */ enum tomoyo_mac_category_index {
TOMOYO_MAC_CATEGORY_FILE,
TOMOYO_MAC_CATEGORY_NETWORK,
TOMOYO_MAC_CATEGORY_MISC,
TOMOYO_MAX_MAC_CATEGORY_INDEX
};
/* * Retry this request. Returned by tomoyo_supervisor() if policy violation has * occurred in enforcing mode and the userspace daemon decided to retry. * * We must choose a positive value in order to distinguish "granted" (which is * 0) and "rejected" (which is a negative value) and "retry".
*/ #define TOMOYO_RETRY_REQUEST 1
/* Index numbers for /sys/kernel/security/tomoyo/stat interface. */ enum tomoyo_policy_stat_type { /* Do not change this order. */
TOMOYO_STAT_POLICY_UPDATES,
TOMOYO_STAT_POLICY_LEARNING, /* == TOMOYO_CONFIG_LEARNING */
TOMOYO_STAT_POLICY_PERMISSIVE, /* == TOMOYO_CONFIG_PERMISSIVE */
TOMOYO_STAT_POLICY_ENFORCING, /* == TOMOYO_CONFIG_ENFORCING */
TOMOYO_MAX_POLICY_STAT
};
/* Index numbers for profile's PREFERENCE values. */ enum tomoyo_pref_index {
TOMOYO_PREF_MAX_AUDIT_LOG,
TOMOYO_PREF_MAX_LEARNING_ENTRY,
TOMOYO_MAX_PREF
};
/********** Structure definitions. **********/
/* Common header for holding ACL entries. */ struct tomoyo_acl_head { struct list_head list;
s8 is_deleted; /* true or false or TOMOYO_GC_IN_PROGRESS */
} __packed;
/* Common header for shared entries. */ struct tomoyo_shared_acl_head { struct list_head list;
atomic_t users;
} __packed;
struct tomoyo_policy_namespace;
/* Structure for request info. */ struct tomoyo_request_info { /* * For holding parameters specific to operations which deal files. * NULL if not dealing files.
*/ struct tomoyo_obj_info *obj; /* * For holding parameters specific to execve() request. * NULL if not dealing execve().
*/ struct tomoyo_execve *ee; struct tomoyo_domain_info *domain; /* For holding parameters. */ union { struct { conststruct tomoyo_path_info *filename; /* For using wildcards at tomoyo_find_next_domain(). */ conststruct tomoyo_path_info *matched_path; /* One of values in "enum tomoyo_path_acl_index". */
u8 operation;
} path; struct { conststruct tomoyo_path_info *filename1; conststruct tomoyo_path_info *filename2; /* One of values in "enum tomoyo_path2_acl_index". */
u8 operation;
} path2; struct { conststruct tomoyo_path_info *filename; unsignedint mode; unsignedint major; unsignedint minor; /* One of values in "enum tomoyo_mkdev_acl_index". */
u8 operation;
} mkdev; struct { conststruct tomoyo_path_info *filename; unsignedlong number; /* * One of values in * "enum tomoyo_path_number_acl_index".
*/
u8 operation;
} path_number; struct { conststruct tomoyo_path_info *name;
} environ; struct { const __be32 *address;
u16 port; /* One of values smaller than TOMOYO_SOCK_MAX. */
u8 protocol; /* One of values in "enum tomoyo_network_acl_index". */
u8 operation; bool is_ipv6;
} inet_network; struct { conststruct tomoyo_path_info *address; /* One of values smaller than TOMOYO_SOCK_MAX. */
u8 protocol; /* One of values in "enum tomoyo_network_acl_index". */
u8 operation;
} unix_network; struct { conststruct tomoyo_path_info *type; conststruct tomoyo_path_info *dir; conststruct tomoyo_path_info *dev; unsignedlong flags; int need_dev;
} mount; struct { conststruct tomoyo_path_info *domainname;
} task;
} param; struct tomoyo_acl_info *matched_acl;
u8 param_type; bool granted;
u8 retry;
u8 profile;
u8 mode; /* One of tomoyo_mode_index . */
u8 type;
};
/* Structure for holding a word. */ struct tomoyo_name_union { /* Either @filename or @group is NULL. */ conststruct tomoyo_path_info *filename; struct tomoyo_group *group;
};
/* Structure for holding a number. */ struct tomoyo_number_union { unsignedlong values[2]; struct tomoyo_group *group; /* Maybe NULL. */ /* One of values in "enum tomoyo_value_type". */
u8 value_type[2];
};
/* Structure for holding an IP address. */ struct tomoyo_ipaddr_union { struct in6_addr ip[2]; /* Big endian. */ struct tomoyo_group *group; /* Pointer to address group. */ bool is_ipv6; /* Valid only if @group == NULL. */
};
/* Structure for "address_group" directive. */ struct tomoyo_address_group { struct tomoyo_acl_head head; /* Structure for holding an IP address. */ struct tomoyo_ipaddr_union address;
};
/* Subset of "struct stat". Used by conditional ACL and audit logs. */ struct tomoyo_mini_stat {
kuid_t uid;
kgid_t gid;
ino_t ino;
umode_t mode;
dev_t dev;
dev_t rdev;
};
/* Structure for dumping argv[] and envp[] of "struct linux_binprm". */ struct tomoyo_page_dump { struct page *page; /* Previously dumped page. */ char *data; /* Contents of "page". Size is PAGE_SIZE. */
};
/* Structure for attribute checks in addition to pathname checks. */ struct tomoyo_obj_info { /* * True if tomoyo_get_attributes() was already called, false otherwise.
*/ bool validate_done; /* True if @stat[] is valid. */ bool stat_valid[TOMOYO_MAX_PATH_STAT]; /* First pathname. Initialized with { NULL, NULL } if no path. */ struct path path1; /* Second pathname. Initialized with { NULL, NULL } if no path. */ struct path path2; /* * Information on @path1, @path1's parent directory, @path2, @path2's * parent directory.
*/ struct tomoyo_mini_stat stat[TOMOYO_MAX_PATH_STAT]; /* * Content of symbolic link to be created. NULL for operations other * than symlink().
*/ struct tomoyo_path_info *symlink_target;
};
/* Structure for execve() operation. */ struct tomoyo_execve { struct tomoyo_request_info r; struct tomoyo_obj_info obj; struct linux_binprm *bprm; conststruct tomoyo_path_info *transition; /* For dumping argv[] and envp[]. */ struct tomoyo_page_dump dump; /* For temporary use. */ char *tmp; /* Size is TOMOYO_EXEC_TMPSIZE bytes */
};
/* Structure for entries which follows "struct tomoyo_condition". */ struct tomoyo_condition_element { /* * Left hand operand. A "struct tomoyo_argv" for TOMOYO_ARGV_ENTRY, a * "struct tomoyo_envp" for TOMOYO_ENVP_ENTRY is attached to the tail * of the array of this struct.
*/
u8 left; /* * Right hand operand. A "struct tomoyo_number_union" for * TOMOYO_NUMBER_UNION, a "struct tomoyo_name_union" for * TOMOYO_NAME_UNION is attached to the tail of the array of this * struct.
*/
u8 right; /* Equation operator. True if equals or overlaps, false otherwise. */ bool equals;
};
/* Structure for optional arguments. */ struct tomoyo_condition { struct tomoyo_shared_acl_head head;
u32 size; /* Memory size allocated for this entry. */
u16 condc; /* Number of conditions in this struct. */
u16 numbers_count; /* Number of "struct tomoyo_number_union values". */
u16 names_count; /* Number of "struct tomoyo_name_union names". */
u16 argc; /* Number of "struct tomoyo_argv". */
u16 envc; /* Number of "struct tomoyo_envp". */
u8 grant_log; /* One of values in "enum tomoyo_grant_log". */ conststruct tomoyo_path_info *transit; /* Maybe NULL. */ /* * struct tomoyo_condition_element condition[condc]; * struct tomoyo_number_union values[numbers_count]; * struct tomoyo_name_union names[names_count]; * struct tomoyo_argv argv[argc]; * struct tomoyo_envp envp[envc];
*/
};
/* Common header for individual entries. */ struct tomoyo_acl_info { struct list_head list; struct tomoyo_condition *cond; /* Maybe NULL. */
s8 is_deleted; /* true or false or TOMOYO_GC_IN_PROGRESS */
u8 type; /* One of values in "enum tomoyo_acl_entry_type_index". */
} __packed;
/* Structure for domain information. */ struct tomoyo_domain_info { struct list_head list; struct list_head acl_info_list; /* Name of this domain. Never NULL. */ conststruct tomoyo_path_info *domainname; /* Namespace for this domain. Never NULL. */ struct tomoyo_policy_namespace *ns; /* Group numbers to use. */ unsignedlong group[TOMOYO_MAX_ACL_GROUPS / BITS_PER_LONG];
u8 profile; /* Profile number to use. */ bool is_deleted; /* Delete flag. */ bool flags[TOMOYO_MAX_DOMAIN_INFO_FLAGS];
atomic_t users; /* Number of referring tasks. */
};
/* * Structure for "task manual_domain_transition" directive.
*/ struct tomoyo_task_acl { struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_MANUAL_TASK_ACL */ /* Pointer to domainname. */ conststruct tomoyo_path_info *domainname;
};
/* Structure for policy manager. */ struct tomoyo_manager { struct tomoyo_acl_head head; /* A path to program or a domainname. */ conststruct tomoyo_path_info *manager;
};
/* Structure for policy namespace. */ struct tomoyo_policy_namespace { /* Profile table. Memory is allocated as needed. */ struct tomoyo_profile *profile_ptr[TOMOYO_MAX_PROFILES]; /* List of "struct tomoyo_group". */ struct list_head group_list[TOMOYO_MAX_GROUP]; /* List of policy. */ struct list_head policy_list[TOMOYO_MAX_POLICY]; /* The global ACL referred by "use_group" keyword. */ struct list_head acl_group[TOMOYO_MAX_ACL_GROUPS]; /* List for connecting to tomoyo_namespace_list list. */ struct list_head namespace_list; /* Profile version. Currently only 20150505 is defined. */ unsignedint profile_version; /* Name of this namespace (e.g. "<kernel>", "</usr/sbin/httpd>" ). */ constchar *name;
};
/** * tomoyo_read_lock - Take lock for protecting policy. * * Returns index number for tomoyo_read_unlock().
*/ staticinlineint tomoyo_read_lock(void)
{ return srcu_read_lock(&tomoyo_ss);
}
/** * tomoyo_read_unlock - Release lock for protecting policy. * * @idx: Index number returned by tomoyo_read_lock(). * * Returns nothing.
*/ staticinlinevoid tomoyo_read_unlock(int idx)
{
srcu_read_unlock(&tomoyo_ss, idx);
}
/** * tomoyo_sys_getppid - Copy of getppid(). * * Returns parent process's PID. * * Alpha does not have getppid() defined. To be able to build this module on * Alpha, I have to copy getppid() from kernel/timer.c.
*/ staticinline pid_t tomoyo_sys_getppid(void)
{
pid_t pid;
/** * tomoyo_sys_getpid - Copy of getpid(). * * Returns current thread's PID. * * Alpha does not have getpid() defined. To be able to build this module on * Alpha, I have to copy getpid() from kernel/timer.c.
*/ staticinline pid_t tomoyo_sys_getpid(void)
{ return task_tgid_vnr(current);
}
/** * tomoyo_current_namespace - Get "struct tomoyo_policy_namespace" for current thread. * * Returns pointer to "struct tomoyo_policy_namespace" for current thread.
*/ staticinlinestruct tomoyo_policy_namespace *tomoyo_current_namespace(void)
{ return tomoyo_domain()->ns;
}
/** * list_for_each_cookie - iterate over a list with cookie. * @pos: the &struct list_head to use as a loop cursor. * @head: the head for your list.
*/ #define list_for_each_cookie(pos, head) \ if (!pos) \
pos = srcu_dereference((head)->next, &tomoyo_ss); \ for ( ; pos != (head); pos = srcu_dereference(pos->next, &tomoyo_ss))
#endif/* !defined(_SECURITY_TOMOYO_COMMON_H) */
Messung V0.5
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.