Commit e2bf6907 authored by Tetsuo Handa's avatar Tetsuo Handa Committed by James Morris

TOMOYO: Rename symbols.

Use shorter name in order to make it easier to fit 80 columns limit.
Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 8e568687
...@@ -248,14 +248,13 @@ static void tomoyo_print_number_union(struct tomoyo_io_buffer *head, ...@@ -248,14 +248,13 @@ static void tomoyo_print_number_union(struct tomoyo_io_buffer *head,
} }
/** /**
* tomoyo_find_or_assign_new_profile - Create a new profile. * tomoyo_assign_profile - Create a new profile.
* *
* @profile: Profile number to create. * @profile: Profile number to create.
* *
* Returns pointer to "struct tomoyo_profile" on success, NULL otherwise. * Returns pointer to "struct tomoyo_profile" on success, NULL otherwise.
*/ */
static struct tomoyo_profile *tomoyo_find_or_assign_new_profile static struct tomoyo_profile *tomoyo_assign_profile(const unsigned int profile)
(const unsigned int profile)
{ {
struct tomoyo_profile *ptr; struct tomoyo_profile *ptr;
struct tomoyo_profile *entry; struct tomoyo_profile *entry;
...@@ -443,7 +442,7 @@ static int tomoyo_write_profile(struct tomoyo_io_buffer *head) ...@@ -443,7 +442,7 @@ static int tomoyo_write_profile(struct tomoyo_io_buffer *head)
if (*cp != '-') if (*cp != '-')
return -EINVAL; return -EINVAL;
data = cp + 1; data = cp + 1;
profile = tomoyo_find_or_assign_new_profile(i); profile = tomoyo_assign_profile(i);
if (!profile) if (!profile)
return -EINVAL; return -EINVAL;
} }
...@@ -584,13 +583,11 @@ static void tomoyo_read_profile(struct tomoyo_io_buffer *head) ...@@ -584,13 +583,11 @@ static void tomoyo_read_profile(struct tomoyo_io_buffer *head)
goto next; goto next;
} }
static bool tomoyo_same_manager_entry(const struct tomoyo_acl_head *a, static bool tomoyo_same_manager(const struct tomoyo_acl_head *a,
const struct tomoyo_acl_head *b) const struct tomoyo_acl_head *b)
{ {
return container_of(a, struct tomoyo_policy_manager_entry, head) return container_of(a, struct tomoyo_manager, head)->manager ==
->manager == container_of(b, struct tomoyo_manager, head)->manager;
container_of(b, struct tomoyo_policy_manager_entry, head)
->manager;
} }
/** /**
...@@ -606,7 +603,7 @@ static bool tomoyo_same_manager_entry(const struct tomoyo_acl_head *a, ...@@ -606,7 +603,7 @@ static bool tomoyo_same_manager_entry(const struct tomoyo_acl_head *a,
static int tomoyo_update_manager_entry(const char *manager, static int tomoyo_update_manager_entry(const char *manager,
const bool is_delete) const bool is_delete)
{ {
struct tomoyo_policy_manager_entry e = { }; struct tomoyo_manager e = { };
int error; int error;
if (tomoyo_domain_def(manager)) { if (tomoyo_domain_def(manager)) {
...@@ -622,13 +619,13 @@ static int tomoyo_update_manager_entry(const char *manager, ...@@ -622,13 +619,13 @@ static int tomoyo_update_manager_entry(const char *manager,
return -ENOMEM; return -ENOMEM;
error = tomoyo_update_policy(&e.head, sizeof(e), is_delete, error = tomoyo_update_policy(&e.head, sizeof(e), is_delete,
&tomoyo_policy_list[TOMOYO_ID_MANAGER], &tomoyo_policy_list[TOMOYO_ID_MANAGER],
tomoyo_same_manager_entry); tomoyo_same_manager);
tomoyo_put_name(e.manager); tomoyo_put_name(e.manager);
return error; return error;
} }
/** /**
* tomoyo_write_manager_policy - Write manager policy. * tomoyo_write_manager - Write manager policy.
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
* *
...@@ -636,7 +633,7 @@ static int tomoyo_update_manager_entry(const char *manager, ...@@ -636,7 +633,7 @@ static int tomoyo_update_manager_entry(const char *manager,
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static int tomoyo_write_manager_policy(struct tomoyo_io_buffer *head) static int tomoyo_write_manager(struct tomoyo_io_buffer *head)
{ {
char *data = head->write_buf; char *data = head->write_buf;
bool is_delete = tomoyo_str_starts(&data, TOMOYO_KEYWORD_DELETE); bool is_delete = tomoyo_str_starts(&data, TOMOYO_KEYWORD_DELETE);
...@@ -649,19 +646,19 @@ static int tomoyo_write_manager_policy(struct tomoyo_io_buffer *head) ...@@ -649,19 +646,19 @@ static int tomoyo_write_manager_policy(struct tomoyo_io_buffer *head)
} }
/** /**
* tomoyo_read_manager_policy - Read manager policy. * tomoyo_read_manager - Read manager policy.
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static void tomoyo_read_manager_policy(struct tomoyo_io_buffer *head) static void tomoyo_read_manager(struct tomoyo_io_buffer *head)
{ {
if (head->r.eof) if (head->r.eof)
return; return;
list_for_each_cookie(head->r.acl, list_for_each_cookie(head->r.acl,
&tomoyo_policy_list[TOMOYO_ID_MANAGER]) { &tomoyo_policy_list[TOMOYO_ID_MANAGER]) {
struct tomoyo_policy_manager_entry *ptr = struct tomoyo_manager *ptr =
list_entry(head->r.acl, typeof(*ptr), head.list); list_entry(head->r.acl, typeof(*ptr), head.list);
if (ptr->head.is_deleted) if (ptr->head.is_deleted)
continue; continue;
...@@ -674,16 +671,16 @@ static void tomoyo_read_manager_policy(struct tomoyo_io_buffer *head) ...@@ -674,16 +671,16 @@ static void tomoyo_read_manager_policy(struct tomoyo_io_buffer *head)
} }
/** /**
* tomoyo_policy_manager - Check whether the current process is a policy manager. * tomoyo_manager - Check whether the current process is a policy manager.
* *
* Returns true if the current process is permitted to modify policy * Returns true if the current process is permitted to modify policy
* via /sys/kernel/security/tomoyo/ interface. * via /sys/kernel/security/tomoyo/ interface.
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static bool tomoyo_policy_manager(void) static bool tomoyo_manager(void)
{ {
struct tomoyo_policy_manager_entry *ptr; struct tomoyo_manager *ptr;
const char *exe; const char *exe;
const struct task_struct *task = current; const struct task_struct *task = current;
const struct tomoyo_path_info *domainname = tomoyo_domain()->domainname; const struct tomoyo_path_info *domainname = tomoyo_domain()->domainname;
...@@ -813,7 +810,7 @@ static int tomoyo_delete_domain(char *domainname) ...@@ -813,7 +810,7 @@ static int tomoyo_delete_domain(char *domainname)
} }
/** /**
* tomoyo_write_domain_policy2 - Write domain policy. * tomoyo_write_domain2 - Write domain policy.
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
* *
...@@ -821,17 +818,16 @@ static int tomoyo_delete_domain(char *domainname) ...@@ -821,17 +818,16 @@ static int tomoyo_delete_domain(char *domainname)
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static int tomoyo_write_domain_policy2(char *data, static int tomoyo_write_domain2(char *data, struct tomoyo_domain_info *domain,
struct tomoyo_domain_info *domain, const bool is_delete)
const bool is_delete)
{ {
if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_ALLOW_MOUNT)) if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_ALLOW_MOUNT))
return tomoyo_write_mount_policy(data, domain, is_delete); return tomoyo_write_mount(data, domain, is_delete);
return tomoyo_write_file_policy(data, domain, is_delete); return tomoyo_write_file(data, domain, is_delete);
} }
/** /**
* tomoyo_write_domain_policy - Write domain policy. * tomoyo_write_domain - Write domain policy.
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
* *
...@@ -839,7 +835,7 @@ static int tomoyo_write_domain_policy2(char *data, ...@@ -839,7 +835,7 @@ static int tomoyo_write_domain_policy2(char *data,
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head) static int tomoyo_write_domain(struct tomoyo_io_buffer *head)
{ {
char *data = head->write_buf; char *data = head->write_buf;
struct tomoyo_domain_info *domain = head->write_var1; struct tomoyo_domain_info *domain = head->write_var1;
...@@ -854,7 +850,7 @@ static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head) ...@@ -854,7 +850,7 @@ static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head)
if (is_select && tomoyo_select_one(head, data)) if (is_select && tomoyo_select_one(head, data))
return 0; return 0;
/* Don't allow updating policies by non manager programs. */ /* Don't allow updating policies by non manager programs. */
if (!tomoyo_policy_manager()) if (!tomoyo_manager())
return -EPERM; return -EPERM;
if (tomoyo_domain_def(data)) { if (tomoyo_domain_def(data)) {
domain = NULL; domain = NULL;
...@@ -863,7 +859,7 @@ static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head) ...@@ -863,7 +859,7 @@ static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head)
else if (is_select) else if (is_select)
domain = tomoyo_find_domain(data); domain = tomoyo_find_domain(data);
else else
domain = tomoyo_find_or_assign_new_domain(data, 0); domain = tomoyo_assign_domain(data, 0);
head->write_var1 = domain; head->write_var1 = domain;
return 0; return 0;
} }
...@@ -888,7 +884,7 @@ static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head) ...@@ -888,7 +884,7 @@ static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head)
domain->transition_failed = !is_delete; domain->transition_failed = !is_delete;
return 0; return 0;
} }
return tomoyo_write_domain_policy2(data, domain, is_delete); return tomoyo_write_domain2(data, domain, is_delete);
} }
/** /**
...@@ -1022,13 +1018,13 @@ static bool tomoyo_read_domain2(struct tomoyo_io_buffer *head, ...@@ -1022,13 +1018,13 @@ static bool tomoyo_read_domain2(struct tomoyo_io_buffer *head,
} }
/** /**
* tomoyo_read_domain_policy - Read domain policy. * tomoyo_read_domain - Read domain policy.
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static void tomoyo_read_domain_policy(struct tomoyo_io_buffer *head) static void tomoyo_read_domain(struct tomoyo_io_buffer *head)
{ {
if (head->r.eof) if (head->r.eof)
return; return;
...@@ -1208,8 +1204,13 @@ static const char *tomoyo_transition_type[TOMOYO_MAX_TRANSITION_TYPE] = { ...@@ -1208,8 +1204,13 @@ static const char *tomoyo_transition_type[TOMOYO_MAX_TRANSITION_TYPE] = {
[TOMOYO_TRANSITION_CONTROL_KEEP] = TOMOYO_KEYWORD_KEEP_DOMAIN [TOMOYO_TRANSITION_CONTROL_KEEP] = TOMOYO_KEYWORD_KEEP_DOMAIN
}; };
static const char *tomoyo_group_name[TOMOYO_MAX_GROUP] = {
[TOMOYO_PATH_GROUP] = TOMOYO_KEYWORD_PATH_GROUP,
[TOMOYO_NUMBER_GROUP] = TOMOYO_KEYWORD_NUMBER_GROUP
};
/** /**
* tomoyo_write_exception_policy - Write exception policy. * tomoyo_write_exception - Write exception policy.
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
* *
...@@ -1217,37 +1218,34 @@ static const char *tomoyo_transition_type[TOMOYO_MAX_TRANSITION_TYPE] = { ...@@ -1217,37 +1218,34 @@ static const char *tomoyo_transition_type[TOMOYO_MAX_TRANSITION_TYPE] = {
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static int tomoyo_write_exception_policy(struct tomoyo_io_buffer *head) static int tomoyo_write_exception(struct tomoyo_io_buffer *head)
{ {
char *data = head->write_buf; char *data = head->write_buf;
bool is_delete = tomoyo_str_starts(&data, TOMOYO_KEYWORD_DELETE); bool is_delete = tomoyo_str_starts(&data, TOMOYO_KEYWORD_DELETE);
u8 i; u8 i;
static const struct {
for (i = 0; i < TOMOYO_MAX_TRANSITION_TYPE; i++) { const char *keyword;
int (*write) (char *, const bool);
} tomoyo_callback[4] = {
{ TOMOYO_KEYWORD_AGGREGATOR, tomoyo_write_aggregator },
{ TOMOYO_KEYWORD_FILE_PATTERN, tomoyo_write_pattern },
{ TOMOYO_KEYWORD_DENY_REWRITE, tomoyo_write_no_rewrite },
{ TOMOYO_KEYWORD_ALLOW_READ, tomoyo_write_globally_readable },
};
for (i = 0; i < TOMOYO_MAX_TRANSITION_TYPE; i++)
if (tomoyo_str_starts(&data, tomoyo_transition_type[i])) if (tomoyo_str_starts(&data, tomoyo_transition_type[i]))
return tomoyo_write_transition_control(data, is_delete, return tomoyo_write_transition_control(data, is_delete,
i); i);
} for (i = 0; i < 4; i++)
if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_AGGREGATOR)) if (tomoyo_str_starts(&data, tomoyo_callback[i].keyword))
return tomoyo_write_aggregator_policy(data, is_delete); return tomoyo_callback[i].write(data, is_delete);
if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_ALLOW_READ)) for (i = 0; i < TOMOYO_MAX_GROUP; i++)
return tomoyo_write_globally_readable_policy(data, is_delete); if (tomoyo_str_starts(&data, tomoyo_group_name[i]))
if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_FILE_PATTERN)) return tomoyo_write_group(data, is_delete, i);
return tomoyo_write_pattern_policy(data, is_delete);
if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_DENY_REWRITE))
return tomoyo_write_no_rewrite_policy(data, is_delete);
if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_PATH_GROUP))
return tomoyo_write_group(data, is_delete, TOMOYO_PATH_GROUP);
if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_NUMBER_GROUP))
return tomoyo_write_group(data, is_delete, TOMOYO_NUMBER_GROUP);
return -EINVAL; return -EINVAL;
} }
static const char *tomoyo_group_name[TOMOYO_MAX_GROUP] = {
[TOMOYO_PATH_GROUP] = TOMOYO_KEYWORD_PATH_GROUP,
[TOMOYO_NUMBER_GROUP] = TOMOYO_KEYWORD_NUMBER_GROUP
};
/** /**
* tomoyo_read_group - Read "struct tomoyo_path_group"/"struct tomoyo_number_group" list. * tomoyo_read_group - Read "struct tomoyo_path_group"/"struct tomoyo_number_group" list.
* *
...@@ -1331,8 +1329,8 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx) ...@@ -1331,8 +1329,8 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx)
break; break;
case TOMOYO_ID_GLOBALLY_READABLE: case TOMOYO_ID_GLOBALLY_READABLE:
{ {
struct tomoyo_globally_readable_file_entry *ptr struct tomoyo_readable_file *ptr =
= container_of(acl, typeof(*ptr), head); container_of(acl, typeof(*ptr), head);
tomoyo_set_string(head, tomoyo_set_string(head,
TOMOYO_KEYWORD_ALLOW_READ); TOMOYO_KEYWORD_ALLOW_READ);
tomoyo_set_string(head, ptr->filename->name); tomoyo_set_string(head, ptr->filename->name);
...@@ -1340,7 +1338,7 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx) ...@@ -1340,7 +1338,7 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx)
break; break;
case TOMOYO_ID_AGGREGATOR: case TOMOYO_ID_AGGREGATOR:
{ {
struct tomoyo_aggregator_entry *ptr = struct tomoyo_aggregator *ptr =
container_of(acl, typeof(*ptr), head); container_of(acl, typeof(*ptr), head);
tomoyo_set_string(head, tomoyo_set_string(head,
TOMOYO_KEYWORD_AGGREGATOR); TOMOYO_KEYWORD_AGGREGATOR);
...@@ -1353,7 +1351,7 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx) ...@@ -1353,7 +1351,7 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx)
break; break;
case TOMOYO_ID_PATTERN: case TOMOYO_ID_PATTERN:
{ {
struct tomoyo_pattern_entry *ptr = struct tomoyo_no_pattern *ptr =
container_of(acl, typeof(*ptr), head); container_of(acl, typeof(*ptr), head);
tomoyo_set_string(head, tomoyo_set_string(head,
TOMOYO_KEYWORD_FILE_PATTERN); TOMOYO_KEYWORD_FILE_PATTERN);
...@@ -1362,7 +1360,7 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx) ...@@ -1362,7 +1360,7 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx)
break; break;
case TOMOYO_ID_NO_REWRITE: case TOMOYO_ID_NO_REWRITE:
{ {
struct tomoyo_no_rewrite_entry *ptr = struct tomoyo_no_rewrite *ptr =
container_of(acl, typeof(*ptr), head); container_of(acl, typeof(*ptr), head);
tomoyo_set_string(head, tomoyo_set_string(head,
TOMOYO_KEYWORD_DENY_REWRITE); TOMOYO_KEYWORD_DENY_REWRITE);
...@@ -1379,13 +1377,13 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx) ...@@ -1379,13 +1377,13 @@ static bool tomoyo_read_policy(struct tomoyo_io_buffer *head, const int idx)
} }
/** /**
* tomoyo_read_exception_policy - Read exception policy. * tomoyo_read_exception - Read exception policy.
* *
* @head: Pointer to "struct tomoyo_io_buffer". * @head: Pointer to "struct tomoyo_io_buffer".
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
static void tomoyo_read_exception_policy(struct tomoyo_io_buffer *head) static void tomoyo_read_exception(struct tomoyo_io_buffer *head)
{ {
if (head->r.eof) if (head->r.eof)
return; return;
...@@ -1472,7 +1470,7 @@ static DECLARE_WAIT_QUEUE_HEAD(tomoyo_query_wait); ...@@ -1472,7 +1470,7 @@ static DECLARE_WAIT_QUEUE_HEAD(tomoyo_query_wait);
static DEFINE_SPINLOCK(tomoyo_query_list_lock); static DEFINE_SPINLOCK(tomoyo_query_list_lock);
/* Structure for query. */ /* Structure for query. */
struct tomoyo_query_entry { struct tomoyo_query {
struct list_head list; struct list_head list;
char *query; char *query;
int query_len; int query_len;
...@@ -1481,7 +1479,7 @@ struct tomoyo_query_entry { ...@@ -1481,7 +1479,7 @@ struct tomoyo_query_entry {
int answer; int answer;
}; };
/* The list for "struct tomoyo_query_entry". */ /* The list for "struct tomoyo_query". */
static LIST_HEAD(tomoyo_query_list); static LIST_HEAD(tomoyo_query_list);
/* /*
...@@ -1508,7 +1506,7 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...) ...@@ -1508,7 +1506,7 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
int pos; int pos;
int len; int len;
static unsigned int tomoyo_serial; static unsigned int tomoyo_serial;
struct tomoyo_query_entry *tomoyo_query_entry = NULL; struct tomoyo_query *entry = NULL;
bool quota_exceeded = false; bool quota_exceeded = false;
char *header; char *header;
switch (r->mode) { switch (r->mode) {
...@@ -1526,7 +1524,7 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...) ...@@ -1526,7 +1524,7 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
vsnprintf(buffer, len - 1, fmt, args); vsnprintf(buffer, len - 1, fmt, args);
va_end(args); va_end(args);
tomoyo_normalize_line(buffer); tomoyo_normalize_line(buffer);
tomoyo_write_domain_policy2(buffer, r->domain, false); tomoyo_write_domain2(buffer, r->domain, false);
kfree(buffer); kfree(buffer);
/* fall through */ /* fall through */
case TOMOYO_CONFIG_PERMISSIVE: case TOMOYO_CONFIG_PERMISSIVE:
...@@ -1542,51 +1540,50 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...) ...@@ -1542,51 +1540,50 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
header = tomoyo_init_audit_log(&len, r); header = tomoyo_init_audit_log(&len, r);
if (!header) if (!header)
goto out; goto out;
tomoyo_query_entry = kzalloc(sizeof(*tomoyo_query_entry), GFP_NOFS); entry = kzalloc(sizeof(*entry), GFP_NOFS);
if (!tomoyo_query_entry) if (!entry)
goto out; goto out;
tomoyo_query_entry->query = kzalloc(len, GFP_NOFS); entry->query = kzalloc(len, GFP_NOFS);
if (!tomoyo_query_entry->query) if (!entry->query)
goto out; goto out;
len = ksize(tomoyo_query_entry->query); len = ksize(entry->query);
INIT_LIST_HEAD(&tomoyo_query_entry->list);
spin_lock(&tomoyo_query_list_lock); spin_lock(&tomoyo_query_list_lock);
if (tomoyo_quota_for_query && tomoyo_query_memory_size + len + if (tomoyo_quota_for_query && tomoyo_query_memory_size + len +
sizeof(*tomoyo_query_entry) >= tomoyo_quota_for_query) { sizeof(*entry) >= tomoyo_quota_for_query) {
quota_exceeded = true; quota_exceeded = true;
} else { } else {
tomoyo_query_memory_size += len + sizeof(*tomoyo_query_entry); tomoyo_query_memory_size += len + sizeof(*entry);
tomoyo_query_entry->serial = tomoyo_serial++; entry->serial = tomoyo_serial++;
} }
spin_unlock(&tomoyo_query_list_lock); spin_unlock(&tomoyo_query_list_lock);
if (quota_exceeded) if (quota_exceeded)
goto out; goto out;
pos = snprintf(tomoyo_query_entry->query, len - 1, "Q%u-%hu\n%s", pos = snprintf(entry->query, len - 1, "Q%u-%hu\n%s",
tomoyo_query_entry->serial, r->retry, header); entry->serial, r->retry, header);
kfree(header); kfree(header);
header = NULL; header = NULL;
va_start(args, fmt); va_start(args, fmt);
vsnprintf(tomoyo_query_entry->query + pos, len - 1 - pos, fmt, args); vsnprintf(entry->query + pos, len - 1 - pos, fmt, args);
tomoyo_query_entry->query_len = strlen(tomoyo_query_entry->query) + 1; entry->query_len = strlen(entry->query) + 1;
va_end(args); va_end(args);
spin_lock(&tomoyo_query_list_lock); spin_lock(&tomoyo_query_list_lock);
list_add_tail(&tomoyo_query_entry->list, &tomoyo_query_list); list_add_tail(&entry->list, &tomoyo_query_list);
spin_unlock(&tomoyo_query_list_lock); spin_unlock(&tomoyo_query_list_lock);
/* Give 10 seconds for supervisor's opinion. */ /* Give 10 seconds for supervisor's opinion. */
for (tomoyo_query_entry->timer = 0; for (entry->timer = 0;
atomic_read(&tomoyo_query_observers) && tomoyo_query_entry->timer < 100; atomic_read(&tomoyo_query_observers) && entry->timer < 100;
tomoyo_query_entry->timer++) { entry->timer++) {
wake_up(&tomoyo_query_wait); wake_up(&tomoyo_query_wait);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ / 10); schedule_timeout(HZ / 10);
if (tomoyo_query_entry->answer) if (entry->answer)
break; break;
} }
spin_lock(&tomoyo_query_list_lock); spin_lock(&tomoyo_query_list_lock);
list_del(&tomoyo_query_entry->list); list_del(&entry->list);
tomoyo_query_memory_size -= len + sizeof(*tomoyo_query_entry); tomoyo_query_memory_size -= len + sizeof(*entry);
spin_unlock(&tomoyo_query_list_lock); spin_unlock(&tomoyo_query_list_lock);
switch (tomoyo_query_entry->answer) { switch (entry->answer) {
case 3: /* Asked to retry by administrator. */ case 3: /* Asked to retry by administrator. */
error = TOMOYO_RETRY_REQUEST; error = TOMOYO_RETRY_REQUEST;
r->retry++; r->retry++;
...@@ -1603,9 +1600,9 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...) ...@@ -1603,9 +1600,9 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
break; break;
} }
out: out:
if (tomoyo_query_entry) if (entry)
kfree(tomoyo_query_entry->query); kfree(entry->query);
kfree(tomoyo_query_entry); kfree(entry);
kfree(header); kfree(header);
return error; return error;
} }
...@@ -1628,9 +1625,8 @@ static int tomoyo_poll_query(struct file *file, poll_table *wait) ...@@ -1628,9 +1625,8 @@ static int tomoyo_poll_query(struct file *file, poll_table *wait)
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
spin_lock(&tomoyo_query_list_lock); spin_lock(&tomoyo_query_list_lock);
list_for_each(tmp, &tomoyo_query_list) { list_for_each(tmp, &tomoyo_query_list) {
struct tomoyo_query_entry *ptr struct tomoyo_query *ptr =
= list_entry(tmp, struct tomoyo_query_entry, list_entry(tmp, typeof(*ptr), list);
list);
if (ptr->answer) if (ptr->answer)
continue; continue;
found = true; found = true;
...@@ -1665,8 +1661,7 @@ static void tomoyo_read_query(struct tomoyo_io_buffer *head) ...@@ -1665,8 +1661,7 @@ static void tomoyo_read_query(struct tomoyo_io_buffer *head)
} }
spin_lock(&tomoyo_query_list_lock); spin_lock(&tomoyo_query_list_lock);
list_for_each(tmp, &tomoyo_query_list) { list_for_each(tmp, &tomoyo_query_list) {
struct tomoyo_query_entry *ptr = struct tomoyo_query *ptr = list_entry(tmp, typeof(*ptr), list);
list_entry(tmp, typeof(*ptr), list);
if (ptr->answer) if (ptr->answer)
continue; continue;
if (pos++ != head->r.query_index) if (pos++ != head->r.query_index)
...@@ -1685,8 +1680,7 @@ static void tomoyo_read_query(struct tomoyo_io_buffer *head) ...@@ -1685,8 +1680,7 @@ static void tomoyo_read_query(struct tomoyo_io_buffer *head)
pos = 0; pos = 0;
spin_lock(&tomoyo_query_list_lock); spin_lock(&tomoyo_query_list_lock);
list_for_each(tmp, &tomoyo_query_list) { list_for_each(tmp, &tomoyo_query_list) {
struct tomoyo_query_entry *ptr = struct tomoyo_query *ptr = list_entry(tmp, typeof(*ptr), list);
list_entry(tmp, typeof(*ptr), list);
if (ptr->answer) if (ptr->answer)
continue; continue;
if (pos++ != head->r.query_index) if (pos++ != head->r.query_index)
...@@ -1724,8 +1718,7 @@ static int tomoyo_write_answer(struct tomoyo_io_buffer *head) ...@@ -1724,8 +1718,7 @@ static int tomoyo_write_answer(struct tomoyo_io_buffer *head)
unsigned int answer; unsigned int answer;
spin_lock(&tomoyo_query_list_lock); spin_lock(&tomoyo_query_list_lock);
list_for_each(tmp, &tomoyo_query_list) { list_for_each(tmp, &tomoyo_query_list) {
struct tomoyo_query_entry *ptr struct tomoyo_query *ptr = list_entry(tmp, typeof(*ptr), list);
= list_entry(tmp, struct tomoyo_query_entry, list);
ptr->timer = 0; ptr->timer = 0;
} }
spin_unlock(&tomoyo_query_list_lock); spin_unlock(&tomoyo_query_list_lock);
...@@ -1733,8 +1726,7 @@ static int tomoyo_write_answer(struct tomoyo_io_buffer *head) ...@@ -1733,8 +1726,7 @@ static int tomoyo_write_answer(struct tomoyo_io_buffer *head)
return -EINVAL; return -EINVAL;
spin_lock(&tomoyo_query_list_lock); spin_lock(&tomoyo_query_list_lock);
list_for_each(tmp, &tomoyo_query_list) { list_for_each(tmp, &tomoyo_query_list) {
struct tomoyo_query_entry *ptr struct tomoyo_query *ptr = list_entry(tmp, typeof(*ptr), list);
= list_entry(tmp, struct tomoyo_query_entry, list);
if (ptr->serial != serial) if (ptr->serial != serial)
continue; continue;
if (!ptr->answer) if (!ptr->answer)
...@@ -1801,13 +1793,13 @@ int tomoyo_open_control(const u8 type, struct file *file) ...@@ -1801,13 +1793,13 @@ int tomoyo_open_control(const u8 type, struct file *file)
switch (type) { switch (type) {
case TOMOYO_DOMAINPOLICY: case TOMOYO_DOMAINPOLICY:
/* /sys/kernel/security/tomoyo/domain_policy */ /* /sys/kernel/security/tomoyo/domain_policy */
head->write = tomoyo_write_domain_policy; head->write = tomoyo_write_domain;
head->read = tomoyo_read_domain_policy; head->read = tomoyo_read_domain;
break; break;
case TOMOYO_EXCEPTIONPOLICY: case TOMOYO_EXCEPTIONPOLICY:
/* /sys/kernel/security/tomoyo/exception_policy */ /* /sys/kernel/security/tomoyo/exception_policy */
head->write = tomoyo_write_exception_policy; head->write = tomoyo_write_exception;
head->read = tomoyo_read_exception_policy; head->read = tomoyo_read_exception;
break; break;
case TOMOYO_SELFDOMAIN: case TOMOYO_SELFDOMAIN:
/* /sys/kernel/security/tomoyo/self_domain */ /* /sys/kernel/security/tomoyo/self_domain */
...@@ -1846,8 +1838,8 @@ int tomoyo_open_control(const u8 type, struct file *file) ...@@ -1846,8 +1838,8 @@ int tomoyo_open_control(const u8 type, struct file *file)
break; break;
case TOMOYO_MANAGER: case TOMOYO_MANAGER:
/* /sys/kernel/security/tomoyo/manager */ /* /sys/kernel/security/tomoyo/manager */
head->write = tomoyo_write_manager_policy; head->write = tomoyo_write_manager;
head->read = tomoyo_read_manager_policy; head->read = tomoyo_read_manager;
break; break;
} }
if (!(file->f_mode & FMODE_READ)) { if (!(file->f_mode & FMODE_READ)) {
...@@ -1905,23 +1897,6 @@ int tomoyo_open_control(const u8 type, struct file *file) ...@@ -1905,23 +1897,6 @@ int tomoyo_open_control(const u8 type, struct file *file)
return 0; return 0;
} }
/**
* tomoyo_poll_control - poll() for /sys/kernel/security/tomoyo/ interface.
*
* @file: Pointer to "struct file".
* @wait: Pointer to "poll_table".
*
* Waits for read readiness.
* /sys/kernel/security/tomoyo/query is handled by /usr/sbin/tomoyo-queryd .
*/
int tomoyo_poll_control(struct file *file, poll_table *wait)
{
struct tomoyo_io_buffer *head = file->private_data;
if (!head->poll)
return -ENOSYS;
return head->poll(file, wait);
}
/** /**
* tomoyo_read_control - read() for /sys/kernel/security/tomoyo/ interface. * tomoyo_read_control - read() for /sys/kernel/security/tomoyo/ interface.
* *
...@@ -1979,8 +1954,7 @@ int tomoyo_write_control(struct file *file, const char __user *buffer, ...@@ -1979,8 +1954,7 @@ int tomoyo_write_control(struct file *file, const char __user *buffer,
return -EFAULT; return -EFAULT;
/* Don't allow updating policies by non manager programs. */ /* Don't allow updating policies by non manager programs. */
if (head->write != tomoyo_write_pid && if (head->write != tomoyo_write_pid &&
head->write != tomoyo_write_domain_policy && head->write != tomoyo_write_domain && !tomoyo_manager())
!tomoyo_policy_manager())
return -EPERM; return -EPERM;
if (mutex_lock_interruptible(&head->io_sem)) if (mutex_lock_interruptible(&head->io_sem))
return -EINTR; return -EINTR;
......
...@@ -310,10 +310,10 @@ struct tomoyo_path_info { ...@@ -310,10 +310,10 @@ struct tomoyo_path_info {
}; };
/* /*
* tomoyo_name_entry is a structure which is used for linking * tomoyo_name is a structure which is used for linking
* "struct tomoyo_path_info" into tomoyo_name_list . * "struct tomoyo_path_info" into tomoyo_name_list .
*/ */
struct tomoyo_name_entry { struct tomoyo_name {
struct list_head list; struct list_head list;
atomic_t users; atomic_t users;
struct tomoyo_path_info entry; struct tomoyo_path_info entry;
...@@ -572,20 +572,20 @@ struct tomoyo_io_buffer { ...@@ -572,20 +572,20 @@ struct tomoyo_io_buffer {
}; };
/* /*
* tomoyo_globally_readable_file_entry is a structure which is used for holding * tomoyo_readable_file is a structure which is used for holding
* "allow_read" entries. * "allow_read" entries.
* It has following fields. * It has following fields.
* *
* (1) "head" is "struct tomoyo_acl_head". * (1) "head" is "struct tomoyo_acl_head".
* (2) "filename" is a pathname which is allowed to open(O_RDONLY). * (2) "filename" is a pathname which is allowed to open(O_RDONLY).
*/ */
struct tomoyo_globally_readable_file_entry { struct tomoyo_readable_file {
struct tomoyo_acl_head head; struct tomoyo_acl_head head;
const struct tomoyo_path_info *filename; const struct tomoyo_path_info *filename;
}; };
/* /*
* tomoyo_pattern_entry is a structure which is used for holding * tomoyo_no_pattern is a structure which is used for holding
* "file_pattern" entries. * "file_pattern" entries.
* It has following fields. * It has following fields.
* *
...@@ -593,13 +593,13 @@ struct tomoyo_globally_readable_file_entry { ...@@ -593,13 +593,13 @@ struct tomoyo_globally_readable_file_entry {
* (2) "pattern" is a pathname pattern which is used for converting pathnames * (2) "pattern" is a pathname pattern which is used for converting pathnames
* to pathname patterns during learning mode. * to pathname patterns during learning mode.
*/ */
struct tomoyo_pattern_entry { struct tomoyo_no_pattern {
struct tomoyo_acl_head head; struct tomoyo_acl_head head;
const struct tomoyo_path_info *pattern; const struct tomoyo_path_info *pattern;
}; };
/* /*
* tomoyo_no_rewrite_entry is a structure which is used for holding * tomoyo_no_rewrite is a structure which is used for holding
* "deny_rewrite" entries. * "deny_rewrite" entries.
* It has following fields. * It has following fields.
* *
...@@ -607,7 +607,7 @@ struct tomoyo_pattern_entry { ...@@ -607,7 +607,7 @@ struct tomoyo_pattern_entry {
* (2) "pattern" is a pathname which is by default not permitted to modify * (2) "pattern" is a pathname which is by default not permitted to modify
* already existing content. * already existing content.
*/ */
struct tomoyo_no_rewrite_entry { struct tomoyo_no_rewrite {
struct tomoyo_acl_head head; struct tomoyo_acl_head head;
const struct tomoyo_path_info *pattern; const struct tomoyo_path_info *pattern;
}; };
...@@ -636,7 +636,7 @@ struct tomoyo_transition_control { ...@@ -636,7 +636,7 @@ struct tomoyo_transition_control {
}; };
/* /*
* tomoyo_aggregator_entry is a structure which is used for holding * tomoyo_aggregator is a structure which is used for holding
* "aggregator" entries. * "aggregator" entries.
* It has following fields. * It has following fields.
* *
...@@ -644,14 +644,14 @@ struct tomoyo_transition_control { ...@@ -644,14 +644,14 @@ struct tomoyo_transition_control {
* (2) "original_name" which is originally requested name. * (2) "original_name" which is originally requested name.
* (3) "aggregated_name" which is name to rewrite. * (3) "aggregated_name" which is name to rewrite.
*/ */
struct tomoyo_aggregator_entry { struct tomoyo_aggregator {
struct tomoyo_acl_head head; struct tomoyo_acl_head head;
const struct tomoyo_path_info *original_name; const struct tomoyo_path_info *original_name;
const struct tomoyo_path_info *aggregated_name; const struct tomoyo_path_info *aggregated_name;
}; };
/* /*
* tomoyo_policy_manager_entry is a structure which is used for holding list of * tomoyo_manager is a structure which is used for holding list of
* domainnames or programs which are permitted to modify configuration via * domainnames or programs which are permitted to modify configuration via
* /sys/kernel/security/tomoyo/ interface. * /sys/kernel/security/tomoyo/ interface.
* It has following fields. * It has following fields.
...@@ -661,7 +661,7 @@ struct tomoyo_aggregator_entry { ...@@ -661,7 +661,7 @@ struct tomoyo_aggregator_entry {
* otherwise. * otherwise.
* (3) "manager" is a domainname or a program's pathname. * (3) "manager" is a domainname or a program's pathname.
*/ */
struct tomoyo_policy_manager_entry { struct tomoyo_manager {
struct tomoyo_acl_head head; struct tomoyo_acl_head head;
bool is_domain; /* True if manager is a domainname. */ bool is_domain; /* True if manager is a domainname. */
/* A path to program or a domainname. */ /* A path to program or a domainname. */
...@@ -749,8 +749,6 @@ bool tomoyo_parse_number_union(char *data, struct tomoyo_number_union *num); ...@@ -749,8 +749,6 @@ bool tomoyo_parse_number_union(char *data, struct tomoyo_number_union *num);
bool tomoyo_tokenize(char *buffer, char *w[], size_t size); bool tomoyo_tokenize(char *buffer, char *w[], size_t size);
/* Write domain policy violation warning message to console? */ /* Write domain policy violation warning message to console? */
bool tomoyo_verbose_mode(const struct tomoyo_domain_info *domain); bool tomoyo_verbose_mode(const struct tomoyo_domain_info *domain);
/* Get the last component of the given domainname. */
const char *tomoyo_get_last_name(const struct tomoyo_domain_info *domain);
/* Fill "struct tomoyo_request_info". */ /* Fill "struct tomoyo_request_info". */
int tomoyo_init_request_info(struct tomoyo_request_info *r, int tomoyo_init_request_info(struct tomoyo_request_info *r,
struct tomoyo_domain_info *domain, struct tomoyo_domain_info *domain,
...@@ -759,7 +757,7 @@ int tomoyo_init_request_info(struct tomoyo_request_info *r, ...@@ -759,7 +757,7 @@ int tomoyo_init_request_info(struct tomoyo_request_info *r,
int tomoyo_mount_permission(char *dev_name, struct path *path, char *type, int tomoyo_mount_permission(char *dev_name, struct path *path, char *type,
unsigned long flags, void *data_page); unsigned long flags, void *data_page);
/* Create "aggregator" entry in exception policy. */ /* Create "aggregator" entry in exception policy. */
int tomoyo_write_aggregator_policy(char *data, const bool is_delete); int tomoyo_write_aggregator(char *data, const bool is_delete);
int tomoyo_write_transition_control(char *data, const bool is_delete, int tomoyo_write_transition_control(char *data, const bool is_delete,
const u8 type); const u8 type);
/* /*
...@@ -769,17 +767,17 @@ int tomoyo_write_transition_control(char *data, const bool is_delete, ...@@ -769,17 +767,17 @@ int tomoyo_write_transition_control(char *data, const bool is_delete,
* "allow_truncate", "allow_symlink", "allow_rewrite", "allow_rename" and * "allow_truncate", "allow_symlink", "allow_rewrite", "allow_rename" and
* "allow_link" entry in domain policy. * "allow_link" entry in domain policy.
*/ */
int tomoyo_write_file_policy(char *data, struct tomoyo_domain_info *domain, int tomoyo_write_file(char *data, struct tomoyo_domain_info *domain,
const bool is_delete); const bool is_delete);
/* Create "allow_read" entry in exception policy. */ /* Create "allow_read" entry in exception policy. */
int tomoyo_write_globally_readable_policy(char *data, const bool is_delete); int tomoyo_write_globally_readable(char *data, const bool is_delete);
/* Create "allow_mount" entry in domain policy. */ /* Create "allow_mount" entry in domain policy. */
int tomoyo_write_mount_policy(char *data, struct tomoyo_domain_info *domain, int tomoyo_write_mount(char *data, struct tomoyo_domain_info *domain,
const bool is_delete); const bool is_delete);
/* Create "deny_rewrite" entry in exception policy. */ /* Create "deny_rewrite" entry in exception policy. */
int tomoyo_write_no_rewrite_policy(char *data, const bool is_delete); int tomoyo_write_no_rewrite(char *data, const bool is_delete);
/* Create "file_pattern" entry in exception policy. */ /* Create "file_pattern" entry in exception policy. */
int tomoyo_write_pattern_policy(char *data, const bool is_delete); int tomoyo_write_pattern(char *data, const bool is_delete);
/* Create "path_group"/"number_group" entry in exception policy. */ /* Create "path_group"/"number_group" entry in exception policy. */
int tomoyo_write_group(char *data, const bool is_delete, const u8 type); int tomoyo_write_group(char *data, const bool is_delete, const u8 type);
int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...) int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
...@@ -787,9 +785,8 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...) ...@@ -787,9 +785,8 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
/* Find a domain by the given name. */ /* Find a domain by the given name. */
struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname); struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname);
/* Find or create a domain by the given name. */ /* Find or create a domain by the given name. */
struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char * struct tomoyo_domain_info *tomoyo_assign_domain(const char *domainname,
domainname, const u8 profile);
const u8 profile);
struct tomoyo_profile *tomoyo_profile(const u8 profile); struct tomoyo_profile *tomoyo_profile(const u8 profile);
/* /*
* Allocate memory for "struct tomoyo_path_group"/"struct tomoyo_number_group". * Allocate memory for "struct tomoyo_path_group"/"struct tomoyo_number_group".
...@@ -820,7 +817,7 @@ char *tomoyo_realpath_nofollow(const char *pathname); ...@@ -820,7 +817,7 @@ char *tomoyo_realpath_nofollow(const char *pathname);
*/ */
char *tomoyo_realpath_from_path(struct path *path); char *tomoyo_realpath_from_path(struct path *path);
/* Get patterned pathname. */ /* Get patterned pathname. */
const char *tomoyo_file_pattern(const struct tomoyo_path_info *filename); const char *tomoyo_pattern(const struct tomoyo_path_info *filename);
/* Check memory quota. */ /* Check memory quota. */
bool tomoyo_memory_ok(void *ptr); bool tomoyo_memory_ok(void *ptr);
...@@ -882,7 +879,6 @@ int tomoyo_update_policy(struct tomoyo_acl_head *new_entry, const int size, ...@@ -882,7 +879,6 @@ int tomoyo_update_policy(struct tomoyo_acl_head *new_entry, const int size,
void tomoyo_check_acl(struct tomoyo_request_info *r, void tomoyo_check_acl(struct tomoyo_request_info *r,
bool (*check_entry) (const struct tomoyo_request_info *, bool (*check_entry) (const struct tomoyo_request_info *,
const struct tomoyo_acl_info *)); const struct tomoyo_acl_info *));
const char *tomoyo_last_word(const char *name);
/********** External variable definitions. **********/ /********** External variable definitions. **********/
...@@ -959,8 +955,8 @@ static inline bool tomoyo_invalid(const unsigned char c) ...@@ -959,8 +955,8 @@ static inline bool tomoyo_invalid(const unsigned char c)
static inline void tomoyo_put_name(const struct tomoyo_path_info *name) static inline void tomoyo_put_name(const struct tomoyo_path_info *name)
{ {
if (name) { if (name) {
struct tomoyo_name_entry *ptr = struct tomoyo_name *ptr =
container_of(name, struct tomoyo_name_entry, entry); container_of(name, typeof(*ptr), entry);
atomic_dec(&ptr->users); atomic_dec(&ptr->users);
} }
} }
......
...@@ -134,26 +134,22 @@ struct list_head tomoyo_policy_list[TOMOYO_MAX_POLICY]; ...@@ -134,26 +134,22 @@ struct list_head tomoyo_policy_list[TOMOYO_MAX_POLICY];
struct list_head tomoyo_group_list[TOMOYO_MAX_GROUP]; struct list_head tomoyo_group_list[TOMOYO_MAX_GROUP];
/** /**
* tomoyo_get_last_name - Get last component of a domainname. * tomoyo_last_word - Get last component of a domainname.
* *
* @domain: Pointer to "struct tomoyo_domain_info". * @domainname: Domainname to check.
* *
* Returns the last component of the domainname. * Returns the last word of @domainname.
*/ */
const char *tomoyo_get_last_name(const struct tomoyo_domain_info *domain) static const char *tomoyo_last_word(const char *name)
{ {
const char *cp0 = domain->domainname->name; const char *cp = strrchr(name, ' ');
const char *cp1 = strrchr(cp0, ' '); if (cp)
return cp + 1;
if (cp1) return name;
return cp1 + 1;
return cp0;
} }
static bool tomoyo_same_transition_control_entry(const struct tomoyo_acl_head * static bool tomoyo_same_transition_control(const struct tomoyo_acl_head *a,
a, const struct tomoyo_acl_head *b)
const struct tomoyo_acl_head *
b)
{ {
const struct tomoyo_transition_control *p1 = container_of(a, const struct tomoyo_transition_control *p1 = container_of(a,
typeof(*p1), typeof(*p1),
...@@ -203,7 +199,7 @@ static int tomoyo_update_transition_control_entry(const char *domainname, ...@@ -203,7 +199,7 @@ static int tomoyo_update_transition_control_entry(const char *domainname,
error = tomoyo_update_policy(&e.head, sizeof(e), is_delete, error = tomoyo_update_policy(&e.head, sizeof(e), is_delete,
&tomoyo_policy_list &tomoyo_policy_list
[TOMOYO_ID_TRANSITION_CONTROL], [TOMOYO_ID_TRANSITION_CONTROL],
tomoyo_same_transition_control_entry); tomoyo_same_transition_control);
out: out:
tomoyo_put_name(e.domainname); tomoyo_put_name(e.domainname);
tomoyo_put_name(e.program); tomoyo_put_name(e.program);
...@@ -292,19 +288,17 @@ static u8 tomoyo_transition_type(const struct tomoyo_path_info *domainname, ...@@ -292,19 +288,17 @@ static u8 tomoyo_transition_type(const struct tomoyo_path_info *domainname,
return type; return type;
} }
static bool tomoyo_same_aggregator_entry(const struct tomoyo_acl_head *a, static bool tomoyo_same_aggregator(const struct tomoyo_acl_head *a,
const struct tomoyo_acl_head *b) const struct tomoyo_acl_head *b)
{ {
const struct tomoyo_aggregator_entry *p1 = container_of(a, typeof(*p1), const struct tomoyo_aggregator *p1 = container_of(a, typeof(*p1), head);
head); const struct tomoyo_aggregator *p2 = container_of(b, typeof(*p2), head);
const struct tomoyo_aggregator_entry *p2 = container_of(b, typeof(*p2),
head);
return p1->original_name == p2->original_name && return p1->original_name == p2->original_name &&
p1->aggregated_name == p2->aggregated_name; p1->aggregated_name == p2->aggregated_name;
} }
/** /**
* tomoyo_update_aggregator_entry - Update "struct tomoyo_aggregator_entry" list. * tomoyo_update_aggregator_entry - Update "struct tomoyo_aggregator" list.
* *
* @original_name: The original program's name. * @original_name: The original program's name.
* @aggregated_name: The program name to use. * @aggregated_name: The program name to use.
...@@ -318,7 +312,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name, ...@@ -318,7 +312,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name,
const char *aggregated_name, const char *aggregated_name,
const bool is_delete) const bool is_delete)
{ {
struct tomoyo_aggregator_entry e = { }; struct tomoyo_aggregator e = { };
int error = is_delete ? -ENOENT : -ENOMEM; int error = is_delete ? -ENOENT : -ENOMEM;
if (!tomoyo_correct_path(original_name) || if (!tomoyo_correct_path(original_name) ||
...@@ -331,7 +325,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name, ...@@ -331,7 +325,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name,
goto out; goto out;
error = tomoyo_update_policy(&e.head, sizeof(e), is_delete, error = tomoyo_update_policy(&e.head, sizeof(e), is_delete,
&tomoyo_policy_list[TOMOYO_ID_AGGREGATOR], &tomoyo_policy_list[TOMOYO_ID_AGGREGATOR],
tomoyo_same_aggregator_entry); tomoyo_same_aggregator);
out: out:
tomoyo_put_name(e.original_name); tomoyo_put_name(e.original_name);
tomoyo_put_name(e.aggregated_name); tomoyo_put_name(e.aggregated_name);
...@@ -339,7 +333,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name, ...@@ -339,7 +333,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name,
} }
/** /**
* tomoyo_write_aggregator_policy - Write "struct tomoyo_aggregator_entry" list. * tomoyo_write_aggregator - Write "struct tomoyo_aggregator" list.
* *
* @data: String to parse. * @data: String to parse.
* @is_delete: True if it is a delete request. * @is_delete: True if it is a delete request.
...@@ -348,7 +342,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name, ...@@ -348,7 +342,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name,
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
int tomoyo_write_aggregator_policy(char *data, const bool is_delete) int tomoyo_write_aggregator(char *data, const bool is_delete)
{ {
char *cp = strchr(data, ' '); char *cp = strchr(data, ' ');
...@@ -359,7 +353,7 @@ int tomoyo_write_aggregator_policy(char *data, const bool is_delete) ...@@ -359,7 +353,7 @@ int tomoyo_write_aggregator_policy(char *data, const bool is_delete)
} }
/** /**
* tomoyo_find_or_assign_new_domain - Create a domain. * tomoyo_assign_domain - Create a domain.
* *
* @domainname: The name of domain. * @domainname: The name of domain.
* @profile: Profile number to assign if the domain was newly created. * @profile: Profile number to assign if the domain was newly created.
...@@ -368,9 +362,8 @@ int tomoyo_write_aggregator_policy(char *data, const bool is_delete) ...@@ -368,9 +362,8 @@ int tomoyo_write_aggregator_policy(char *data, const bool is_delete)
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char * struct tomoyo_domain_info *tomoyo_assign_domain(const char *domainname,
domainname, const u8 profile)
const u8 profile)
{ {
struct tomoyo_domain_info *entry; struct tomoyo_domain_info *entry;
struct tomoyo_domain_info *domain = NULL; struct tomoyo_domain_info *domain = NULL;
...@@ -430,10 +423,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm) ...@@ -430,10 +423,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)
int retval = -ENOMEM; int retval = -ENOMEM;
bool need_kfree = false; bool need_kfree = false;
struct tomoyo_path_info rn = { }; /* real name */ struct tomoyo_path_info rn = { }; /* real name */
struct tomoyo_path_info ln; /* last name */
ln.name = tomoyo_get_last_name(old_domain);
tomoyo_fill_path_info(&ln);
mode = tomoyo_init_request_info(&r, NULL, TOMOYO_MAC_FILE_EXECUTE); mode = tomoyo_init_request_info(&r, NULL, TOMOYO_MAC_FILE_EXECUTE);
is_enforce = (mode == TOMOYO_CONFIG_ENFORCING); is_enforce = (mode == TOMOYO_CONFIG_ENFORCING);
if (!tmp) if (!tmp)
...@@ -454,7 +444,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm) ...@@ -454,7 +444,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)
/* Check 'aggregator' directive. */ /* Check 'aggregator' directive. */
{ {
struct tomoyo_aggregator_entry *ptr; struct tomoyo_aggregator *ptr;
list_for_each_entry_rcu(ptr, &tomoyo_policy_list list_for_each_entry_rcu(ptr, &tomoyo_policy_list
[TOMOYO_ID_AGGREGATOR], head.list) { [TOMOYO_ID_AGGREGATOR], head.list) {
if (ptr->head.is_deleted || if (ptr->head.is_deleted ||
...@@ -517,7 +507,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm) ...@@ -517,7 +507,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)
if (error < 0) if (error < 0)
goto done; goto done;
} }
domain = tomoyo_find_or_assign_new_domain(tmp, old_domain->profile); domain = tomoyo_assign_domain(tmp, old_domain->profile);
done: done:
if (domain) if (domain)
goto out; goto out;
......
...@@ -179,7 +179,7 @@ static int tomoyo_audit_path_log(struct tomoyo_request_info *r) ...@@ -179,7 +179,7 @@ static int tomoyo_audit_path_log(struct tomoyo_request_info *r)
return 0; return 0;
tomoyo_warn_log(r, "%s %s", operation, filename->name); tomoyo_warn_log(r, "%s %s", operation, filename->name);
return tomoyo_supervisor(r, "allow_%s %s\n", operation, return tomoyo_supervisor(r, "allow_%s %s\n", operation,
tomoyo_file_pattern(filename)); tomoyo_pattern(filename));
} }
/** /**
...@@ -199,8 +199,8 @@ static int tomoyo_audit_path2_log(struct tomoyo_request_info *r) ...@@ -199,8 +199,8 @@ static int tomoyo_audit_path2_log(struct tomoyo_request_info *r)
tomoyo_warn_log(r, "%s %s %s", operation, filename1->name, tomoyo_warn_log(r, "%s %s %s", operation, filename1->name,
filename2->name); filename2->name);
return tomoyo_supervisor(r, "allow_%s %s %s\n", operation, return tomoyo_supervisor(r, "allow_%s %s %s\n", operation,
tomoyo_file_pattern(filename1), tomoyo_pattern(filename1),
tomoyo_file_pattern(filename2)); tomoyo_pattern(filename2));
} }
/** /**
...@@ -222,8 +222,7 @@ static int tomoyo_audit_mkdev_log(struct tomoyo_request_info *r) ...@@ -222,8 +222,7 @@ static int tomoyo_audit_mkdev_log(struct tomoyo_request_info *r)
tomoyo_warn_log(r, "%s %s 0%o %u %u", operation, filename->name, mode, tomoyo_warn_log(r, "%s %s 0%o %u %u", operation, filename->name, mode,
major, minor); major, minor);
return tomoyo_supervisor(r, "allow_%s %s 0%o %u %u\n", operation, return tomoyo_supervisor(r, "allow_%s %s 0%o %u %u\n", operation,
tomoyo_file_pattern(filename), mode, major, tomoyo_pattern(filename), mode, major, minor);
minor);
} }
/** /**
...@@ -262,20 +261,20 @@ static int tomoyo_audit_path_number_log(struct tomoyo_request_info *r) ...@@ -262,20 +261,20 @@ static int tomoyo_audit_path_number_log(struct tomoyo_request_info *r)
radix); radix);
tomoyo_warn_log(r, "%s %s %s", operation, filename->name, buffer); tomoyo_warn_log(r, "%s %s %s", operation, filename->name, buffer);
return tomoyo_supervisor(r, "allow_%s %s %s\n", operation, return tomoyo_supervisor(r, "allow_%s %s %s\n", operation,
tomoyo_file_pattern(filename), buffer); tomoyo_pattern(filename), buffer);
} }
static bool tomoyo_same_globally_readable(const struct tomoyo_acl_head *a, static bool tomoyo_same_globally_readable(const struct tomoyo_acl_head *a,
const struct tomoyo_acl_head *b) const struct tomoyo_acl_head *b)
{ {
return container_of(a, struct tomoyo_globally_readable_file_entry, return container_of(a, struct tomoyo_readable_file,
head)->filename == head)->filename ==
container_of(b, struct tomoyo_globally_readable_file_entry, container_of(b, struct tomoyo_readable_file,
head)->filename; head)->filename;
} }
/** /**
* tomoyo_update_globally_readable_entry - Update "struct tomoyo_globally_readable_file_entry" list. * tomoyo_update_globally_readable_entry - Update "struct tomoyo_readable_file" list.
* *
* @filename: Filename unconditionally permitted to open() for reading. * @filename: Filename unconditionally permitted to open() for reading.
* @is_delete: True if it is a delete request. * @is_delete: True if it is a delete request.
...@@ -287,7 +286,7 @@ static bool tomoyo_same_globally_readable(const struct tomoyo_acl_head *a, ...@@ -287,7 +286,7 @@ static bool tomoyo_same_globally_readable(const struct tomoyo_acl_head *a,
static int tomoyo_update_globally_readable_entry(const char *filename, static int tomoyo_update_globally_readable_entry(const char *filename,
const bool is_delete) const bool is_delete)
{ {
struct tomoyo_globally_readable_file_entry e = { }; struct tomoyo_readable_file e = { };
int error; int error;
if (!tomoyo_correct_word(filename)) if (!tomoyo_correct_word(filename))
...@@ -315,7 +314,7 @@ static int tomoyo_update_globally_readable_entry(const char *filename, ...@@ -315,7 +314,7 @@ static int tomoyo_update_globally_readable_entry(const char *filename,
static bool tomoyo_globally_readable_file(const struct tomoyo_path_info * static bool tomoyo_globally_readable_file(const struct tomoyo_path_info *
filename) filename)
{ {
struct tomoyo_globally_readable_file_entry *ptr; struct tomoyo_readable_file *ptr;
bool found = false; bool found = false;
list_for_each_entry_rcu(ptr, &tomoyo_policy_list list_for_each_entry_rcu(ptr, &tomoyo_policy_list
...@@ -330,7 +329,7 @@ static bool tomoyo_globally_readable_file(const struct tomoyo_path_info * ...@@ -330,7 +329,7 @@ static bool tomoyo_globally_readable_file(const struct tomoyo_path_info *
} }
/** /**
* tomoyo_write_globally_readable_policy - Write "struct tomoyo_globally_readable_file_entry" list. * tomoyo_write_globally_readable - Write "struct tomoyo_readable_file" list.
* *
* @data: String to parse. * @data: String to parse.
* @is_delete: True if it is a delete request. * @is_delete: True if it is a delete request.
...@@ -339,7 +338,7 @@ static bool tomoyo_globally_readable_file(const struct tomoyo_path_info * ...@@ -339,7 +338,7 @@ static bool tomoyo_globally_readable_file(const struct tomoyo_path_info *
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
int tomoyo_write_globally_readable_policy(char *data, const bool is_delete) int tomoyo_write_globally_readable(char *data, const bool is_delete)
{ {
return tomoyo_update_globally_readable_entry(data, is_delete); return tomoyo_update_globally_readable_entry(data, is_delete);
} }
...@@ -347,12 +346,12 @@ int tomoyo_write_globally_readable_policy(char *data, const bool is_delete) ...@@ -347,12 +346,12 @@ int tomoyo_write_globally_readable_policy(char *data, const bool is_delete)
static bool tomoyo_same_pattern(const struct tomoyo_acl_head *a, static bool tomoyo_same_pattern(const struct tomoyo_acl_head *a,
const struct tomoyo_acl_head *b) const struct tomoyo_acl_head *b)
{ {
return container_of(a, struct tomoyo_pattern_entry, head)->pattern == return container_of(a, struct tomoyo_no_pattern, head)->pattern ==
container_of(b, struct tomoyo_pattern_entry, head)->pattern; container_of(b, struct tomoyo_no_pattern, head)->pattern;
} }
/** /**
* tomoyo_update_file_pattern_entry - Update "struct tomoyo_pattern_entry" list. * tomoyo_update_file_pattern_entry - Update "struct tomoyo_no_pattern" list.
* *
* @pattern: Pathname pattern. * @pattern: Pathname pattern.
* @is_delete: True if it is a delete request. * @is_delete: True if it is a delete request.
...@@ -364,7 +363,7 @@ static bool tomoyo_same_pattern(const struct tomoyo_acl_head *a, ...@@ -364,7 +363,7 @@ static bool tomoyo_same_pattern(const struct tomoyo_acl_head *a,
static int tomoyo_update_file_pattern_entry(const char *pattern, static int tomoyo_update_file_pattern_entry(const char *pattern,
const bool is_delete) const bool is_delete)
{ {
struct tomoyo_pattern_entry e = { }; struct tomoyo_no_pattern e = { };
int error; int error;
if (!tomoyo_correct_word(pattern)) if (!tomoyo_correct_word(pattern))
...@@ -380,7 +379,7 @@ static int tomoyo_update_file_pattern_entry(const char *pattern, ...@@ -380,7 +379,7 @@ static int tomoyo_update_file_pattern_entry(const char *pattern,
} }
/** /**
* tomoyo_file_pattern - Get patterned pathname. * tomoyo_pattern - Get patterned pathname.
* *
* @filename: The filename to find patterned pathname. * @filename: The filename to find patterned pathname.
* *
...@@ -388,9 +387,9 @@ static int tomoyo_update_file_pattern_entry(const char *pattern, ...@@ -388,9 +387,9 @@ static int tomoyo_update_file_pattern_entry(const char *pattern,
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
const char *tomoyo_file_pattern(const struct tomoyo_path_info *filename) const char *tomoyo_pattern(const struct tomoyo_path_info *filename)
{ {
struct tomoyo_pattern_entry *ptr; struct tomoyo_no_pattern *ptr;
const struct tomoyo_path_info *pattern = NULL; const struct tomoyo_path_info *pattern = NULL;
list_for_each_entry_rcu(ptr, &tomoyo_policy_list[TOMOYO_ID_PATTERN], list_for_each_entry_rcu(ptr, &tomoyo_policy_list[TOMOYO_ID_PATTERN],
...@@ -413,7 +412,7 @@ const char *tomoyo_file_pattern(const struct tomoyo_path_info *filename) ...@@ -413,7 +412,7 @@ const char *tomoyo_file_pattern(const struct tomoyo_path_info *filename)
} }
/** /**
* tomoyo_write_pattern_policy - Write "struct tomoyo_pattern_entry" list. * tomoyo_write_pattern - Write "struct tomoyo_no_pattern" list.
* *
* @data: String to parse. * @data: String to parse.
* @is_delete: True if it is a delete request. * @is_delete: True if it is a delete request.
...@@ -422,7 +421,7 @@ const char *tomoyo_file_pattern(const struct tomoyo_path_info *filename) ...@@ -422,7 +421,7 @@ const char *tomoyo_file_pattern(const struct tomoyo_path_info *filename)
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
int tomoyo_write_pattern_policy(char *data, const bool is_delete) int tomoyo_write_pattern(char *data, const bool is_delete)
{ {
return tomoyo_update_file_pattern_entry(data, is_delete); return tomoyo_update_file_pattern_entry(data, is_delete);
} }
...@@ -430,13 +429,13 @@ int tomoyo_write_pattern_policy(char *data, const bool is_delete) ...@@ -430,13 +429,13 @@ int tomoyo_write_pattern_policy(char *data, const bool is_delete)
static bool tomoyo_same_no_rewrite(const struct tomoyo_acl_head *a, static bool tomoyo_same_no_rewrite(const struct tomoyo_acl_head *a,
const struct tomoyo_acl_head *b) const struct tomoyo_acl_head *b)
{ {
return container_of(a, struct tomoyo_no_rewrite_entry, head)->pattern return container_of(a, struct tomoyo_no_rewrite, head)->pattern
== container_of(b, struct tomoyo_no_rewrite_entry, head) == container_of(b, struct tomoyo_no_rewrite, head)
->pattern; ->pattern;
} }
/** /**
* tomoyo_update_no_rewrite_entry - Update "struct tomoyo_no_rewrite_entry" list. * tomoyo_update_no_rewrite_entry - Update "struct tomoyo_no_rewrite" list.
* *
* @pattern: Pathname pattern that are not rewritable by default. * @pattern: Pathname pattern that are not rewritable by default.
* @is_delete: True if it is a delete request. * @is_delete: True if it is a delete request.
...@@ -448,7 +447,7 @@ static bool tomoyo_same_no_rewrite(const struct tomoyo_acl_head *a, ...@@ -448,7 +447,7 @@ static bool tomoyo_same_no_rewrite(const struct tomoyo_acl_head *a,
static int tomoyo_update_no_rewrite_entry(const char *pattern, static int tomoyo_update_no_rewrite_entry(const char *pattern,
const bool is_delete) const bool is_delete)
{ {
struct tomoyo_no_rewrite_entry e = { }; struct tomoyo_no_rewrite e = { };
int error; int error;
if (!tomoyo_correct_word(pattern)) if (!tomoyo_correct_word(pattern))
...@@ -475,7 +474,7 @@ static int tomoyo_update_no_rewrite_entry(const char *pattern, ...@@ -475,7 +474,7 @@ static int tomoyo_update_no_rewrite_entry(const char *pattern,
*/ */
static bool tomoyo_no_rewrite_file(const struct tomoyo_path_info *filename) static bool tomoyo_no_rewrite_file(const struct tomoyo_path_info *filename)
{ {
struct tomoyo_no_rewrite_entry *ptr; struct tomoyo_no_rewrite *ptr;
bool found = false; bool found = false;
list_for_each_entry_rcu(ptr, &tomoyo_policy_list[TOMOYO_ID_NO_REWRITE], list_for_each_entry_rcu(ptr, &tomoyo_policy_list[TOMOYO_ID_NO_REWRITE],
...@@ -491,7 +490,7 @@ static bool tomoyo_no_rewrite_file(const struct tomoyo_path_info *filename) ...@@ -491,7 +490,7 @@ static bool tomoyo_no_rewrite_file(const struct tomoyo_path_info *filename)
} }
/** /**
* tomoyo_write_no_rewrite_policy - Write "struct tomoyo_no_rewrite_entry" list. * tomoyo_write_no_rewrite - Write "struct tomoyo_no_rewrite" list.
* *
* @data: String to parse. * @data: String to parse.
* @is_delete: True if it is a delete request. * @is_delete: True if it is a delete request.
...@@ -500,7 +499,7 @@ static bool tomoyo_no_rewrite_file(const struct tomoyo_path_info *filename) ...@@ -500,7 +499,7 @@ static bool tomoyo_no_rewrite_file(const struct tomoyo_path_info *filename)
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
int tomoyo_write_no_rewrite_policy(char *data, const bool is_delete) int tomoyo_write_no_rewrite(char *data, const bool is_delete)
{ {
return tomoyo_update_no_rewrite_entry(data, is_delete); return tomoyo_update_no_rewrite_entry(data, is_delete);
} }
...@@ -1121,7 +1120,7 @@ int tomoyo_path2_perm(const u8 operation, struct path *path1, ...@@ -1121,7 +1120,7 @@ int tomoyo_path2_perm(const u8 operation, struct path *path1,
} }
/** /**
* tomoyo_write_file_policy - Update file related list. * tomoyo_write_file - Update file related list.
* *
* @data: String to parse. * @data: String to parse.
* @domain: Pointer to "struct tomoyo_domain_info". * @domain: Pointer to "struct tomoyo_domain_info".
...@@ -1131,8 +1130,8 @@ int tomoyo_path2_perm(const u8 operation, struct path *path1, ...@@ -1131,8 +1130,8 @@ int tomoyo_path2_perm(const u8 operation, struct path *path1,
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
int tomoyo_write_file_policy(char *data, struct tomoyo_domain_info *domain, int tomoyo_write_file(char *data, struct tomoyo_domain_info *domain,
const bool is_delete) const bool is_delete)
{ {
char *w[5]; char *w[5];
u8 type; u8 type;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/slab.h> #include <linux/slab.h>
struct tomoyo_gc_entry { struct tomoyo_gc {
struct list_head list; struct list_head list;
int type; int type;
struct list_head *element; struct list_head *element;
...@@ -22,7 +22,7 @@ static DEFINE_MUTEX(tomoyo_gc_mutex); ...@@ -22,7 +22,7 @@ static DEFINE_MUTEX(tomoyo_gc_mutex);
/* Caller holds tomoyo_policy_lock mutex. */ /* Caller holds tomoyo_policy_lock mutex. */
static bool tomoyo_add_to_gc(const int type, struct list_head *element) static bool tomoyo_add_to_gc(const int type, struct list_head *element)
{ {
struct tomoyo_gc_entry *entry = kzalloc(sizeof(*entry), GFP_ATOMIC); struct tomoyo_gc *entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry) if (!entry)
return false; return false;
entry->type = type; entry->type = type;
...@@ -34,21 +34,21 @@ static bool tomoyo_add_to_gc(const int type, struct list_head *element) ...@@ -34,21 +34,21 @@ static bool tomoyo_add_to_gc(const int type, struct list_head *element)
static void tomoyo_del_allow_read(struct list_head *element) static void tomoyo_del_allow_read(struct list_head *element)
{ {
struct tomoyo_globally_readable_file_entry *ptr = struct tomoyo_readable_file *ptr =
container_of(element, typeof(*ptr), head.list); container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->filename); tomoyo_put_name(ptr->filename);
} }
static void tomoyo_del_file_pattern(struct list_head *element) static void tomoyo_del_file_pattern(struct list_head *element)
{ {
struct tomoyo_pattern_entry *ptr = struct tomoyo_no_pattern *ptr =
container_of(element, typeof(*ptr), head.list); container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->pattern); tomoyo_put_name(ptr->pattern);
} }
static void tomoyo_del_no_rewrite(struct list_head *element) static void tomoyo_del_no_rewrite(struct list_head *element)
{ {
struct tomoyo_no_rewrite_entry *ptr = struct tomoyo_no_rewrite *ptr =
container_of(element, typeof(*ptr), head.list); container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->pattern); tomoyo_put_name(ptr->pattern);
} }
...@@ -63,7 +63,7 @@ static void tomoyo_del_transition_control(struct list_head *element) ...@@ -63,7 +63,7 @@ static void tomoyo_del_transition_control(struct list_head *element)
static void tomoyo_del_aggregator(struct list_head *element) static void tomoyo_del_aggregator(struct list_head *element)
{ {
struct tomoyo_aggregator_entry *ptr = struct tomoyo_aggregator *ptr =
container_of(element, typeof(*ptr), head.list); container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->original_name); tomoyo_put_name(ptr->original_name);
tomoyo_put_name(ptr->aggregated_name); tomoyo_put_name(ptr->aggregated_name);
...@@ -71,7 +71,7 @@ static void tomoyo_del_aggregator(struct list_head *element) ...@@ -71,7 +71,7 @@ static void tomoyo_del_aggregator(struct list_head *element)
static void tomoyo_del_manager(struct list_head *element) static void tomoyo_del_manager(struct list_head *element)
{ {
struct tomoyo_policy_manager_entry *ptr = struct tomoyo_manager *ptr =
container_of(element, typeof(*ptr), head.list); container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->manager); tomoyo_put_name(ptr->manager);
} }
...@@ -168,7 +168,7 @@ static bool tomoyo_del_domain(struct list_head *element) ...@@ -168,7 +168,7 @@ static bool tomoyo_del_domain(struct list_head *element)
static void tomoyo_del_name(struct list_head *element) static void tomoyo_del_name(struct list_head *element)
{ {
const struct tomoyo_name_entry *ptr = const struct tomoyo_name *ptr =
container_of(element, typeof(*ptr), list); container_of(element, typeof(*ptr), list);
} }
...@@ -242,7 +242,7 @@ static void tomoyo_collect_entry(void) ...@@ -242,7 +242,7 @@ static void tomoyo_collect_entry(void)
} }
} }
for (i = 0; i < TOMOYO_MAX_HASH; i++) { for (i = 0; i < TOMOYO_MAX_HASH; i++) {
struct tomoyo_name_entry *ptr; struct tomoyo_name *ptr;
list_for_each_entry_rcu(ptr, &tomoyo_name_list[i], list) { list_for_each_entry_rcu(ptr, &tomoyo_name_list[i], list) {
if (atomic_read(&ptr->users)) if (atomic_read(&ptr->users))
continue; continue;
...@@ -278,8 +278,8 @@ static void tomoyo_collect_entry(void) ...@@ -278,8 +278,8 @@ static void tomoyo_collect_entry(void)
static void tomoyo_kfree_entry(void) static void tomoyo_kfree_entry(void)
{ {
struct tomoyo_gc_entry *p; struct tomoyo_gc *p;
struct tomoyo_gc_entry *tmp; struct tomoyo_gc *tmp;
list_for_each_entry_safe(p, tmp, &tomoyo_gc_queue, list) { list_for_each_entry_safe(p, tmp, &tomoyo_gc_queue, list) {
struct list_head *element = p->element; struct list_head *element = p->element;
......
...@@ -150,7 +150,7 @@ struct list_head tomoyo_name_list[TOMOYO_MAX_HASH]; ...@@ -150,7 +150,7 @@ struct list_head tomoyo_name_list[TOMOYO_MAX_HASH];
*/ */
const struct tomoyo_path_info *tomoyo_get_name(const char *name) const struct tomoyo_path_info *tomoyo_get_name(const char *name)
{ {
struct tomoyo_name_entry *ptr; struct tomoyo_name *ptr;
unsigned int hash; unsigned int hash;
int len; int len;
int allocated_len; int allocated_len;
......
...@@ -55,8 +55,8 @@ static int tomoyo_audit_mount_log(struct tomoyo_request_info *r) ...@@ -55,8 +55,8 @@ static int tomoyo_audit_mount_log(struct tomoyo_request_info *r)
flags); flags);
return tomoyo_supervisor(r, return tomoyo_supervisor(r,
TOMOYO_KEYWORD_ALLOW_MOUNT "%s %s %s 0x%lX\n", TOMOYO_KEYWORD_ALLOW_MOUNT "%s %s %s 0x%lX\n",
tomoyo_file_pattern(r->param.mount.dev), tomoyo_pattern(r->param.mount.dev),
tomoyo_file_pattern(r->param.mount.dir), type, tomoyo_pattern(r->param.mount.dir), type,
flags); flags);
} }
...@@ -250,7 +250,7 @@ static bool tomoyo_same_mount_acl(const struct tomoyo_acl_info *a, ...@@ -250,7 +250,7 @@ static bool tomoyo_same_mount_acl(const struct tomoyo_acl_info *a,
} }
/** /**
* tomoyo_write_mount_policy - Write "struct tomoyo_mount_acl" list. * tomoyo_write_mount - Write "struct tomoyo_mount_acl" list.
* *
* @data: String to parse. * @data: String to parse.
* @domain: Pointer to "struct tomoyo_domain_info". * @domain: Pointer to "struct tomoyo_domain_info".
...@@ -260,8 +260,8 @@ static bool tomoyo_same_mount_acl(const struct tomoyo_acl_info *a, ...@@ -260,8 +260,8 @@ static bool tomoyo_same_mount_acl(const struct tomoyo_acl_info *a,
* *
* Caller holds tomoyo_read_lock(). * Caller holds tomoyo_read_lock().
*/ */
int tomoyo_write_mount_policy(char *data, struct tomoyo_domain_info *domain, int tomoyo_write_mount(char *data, struct tomoyo_domain_info *domain,
const bool is_delete) const bool is_delete)
{ {
struct tomoyo_mount_acl e = { .head.type = TOMOYO_TYPE_MOUNT_ACL }; struct tomoyo_mount_acl e = { .head.type = TOMOYO_TYPE_MOUNT_ACL };
int error = is_delete ? -ENOENT : -ENOMEM; int error = is_delete ? -ENOENT : -ENOMEM;
......
...@@ -26,7 +26,7 @@ bool tomoyo_policy_loaded; ...@@ -26,7 +26,7 @@ bool tomoyo_policy_loaded;
* The @src is updated to point the first character after the value * The @src is updated to point the first character after the value
* on success. * on success.
*/ */
u8 tomoyo_parse_ulong(unsigned long *result, char **str) static u8 tomoyo_parse_ulong(unsigned long *result, char **str)
{ {
const char *cp = *str; const char *cp = *str;
char *ep; char *ep;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment