diff options
Diffstat (limited to 'security/tomoyo/common.c')
-rw-r--r-- | security/tomoyo/common.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c index c668b447c725..a0d09e56874b 100644 --- a/security/tomoyo/common.c +++ b/security/tomoyo/common.c | |||
@@ -108,10 +108,9 @@ static bool tomoyo_flush(struct tomoyo_io_buffer *head) | |||
108 | head->read_user_buf += len; | 108 | head->read_user_buf += len; |
109 | w += len; | 109 | w += len; |
110 | } | 110 | } |
111 | if (*w) { | 111 | head->r.w[0] = w; |
112 | head->r.w[0] = w; | 112 | if (*w) |
113 | return false; | 113 | return false; |
114 | } | ||
115 | /* Add '\0' for query. */ | 114 | /* Add '\0' for query. */ |
116 | if (head->poll) { | 115 | if (head->poll) { |
117 | if (!head->read_user_buf_avail || | 116 | if (!head->read_user_buf_avail || |
@@ -459,8 +458,16 @@ static int tomoyo_write_profile(struct tomoyo_io_buffer *head) | |||
459 | if (profile == &tomoyo_default_profile) | 458 | if (profile == &tomoyo_default_profile) |
460 | return -EINVAL; | 459 | return -EINVAL; |
461 | if (!strcmp(data, "COMMENT")) { | 460 | if (!strcmp(data, "COMMENT")) { |
462 | const struct tomoyo_path_info *old_comment = profile->comment; | 461 | static DEFINE_SPINLOCK(lock); |
463 | profile->comment = tomoyo_get_name(cp); | 462 | const struct tomoyo_path_info *new_comment |
463 | = tomoyo_get_name(cp); | ||
464 | const struct tomoyo_path_info *old_comment; | ||
465 | if (!new_comment) | ||
466 | return -ENOMEM; | ||
467 | spin_lock(&lock); | ||
468 | old_comment = profile->comment; | ||
469 | profile->comment = new_comment; | ||
470 | spin_unlock(&lock); | ||
464 | tomoyo_put_name(old_comment); | 471 | tomoyo_put_name(old_comment); |
465 | return 0; | 472 | return 0; |
466 | } | 473 | } |
@@ -768,8 +775,10 @@ static bool tomoyo_select_one(struct tomoyo_io_buffer *head, const char *data) | |||
768 | return true; /* Do nothing if open(O_WRONLY). */ | 775 | return true; /* Do nothing if open(O_WRONLY). */ |
769 | memset(&head->r, 0, sizeof(head->r)); | 776 | memset(&head->r, 0, sizeof(head->r)); |
770 | head->r.print_this_domain_only = true; | 777 | head->r.print_this_domain_only = true; |
771 | head->r.eof = !domain; | 778 | if (domain) |
772 | head->r.domain = &domain->list; | 779 | head->r.domain = &domain->list; |
780 | else | ||
781 | head->r.eof = 1; | ||
773 | tomoyo_io_printf(head, "# select %s\n", data); | 782 | tomoyo_io_printf(head, "# select %s\n", data); |
774 | if (domain && domain->is_deleted) | 783 | if (domain && domain->is_deleted) |
775 | tomoyo_io_printf(head, "# This is a deleted domain.\n"); | 784 | tomoyo_io_printf(head, "# This is a deleted domain.\n"); |
@@ -2051,13 +2060,22 @@ void tomoyo_check_profile(void) | |||
2051 | const u8 profile = domain->profile; | 2060 | const u8 profile = domain->profile; |
2052 | if (tomoyo_profile_ptr[profile]) | 2061 | if (tomoyo_profile_ptr[profile]) |
2053 | continue; | 2062 | continue; |
2063 | printk(KERN_ERR "You need to define profile %u before using it.\n", | ||
2064 | profile); | ||
2065 | printk(KERN_ERR "Please see http://tomoyo.sourceforge.jp/2.3/ " | ||
2066 | "for more information.\n"); | ||
2054 | panic("Profile %u (used by '%s') not defined.\n", | 2067 | panic("Profile %u (used by '%s') not defined.\n", |
2055 | profile, domain->domainname->name); | 2068 | profile, domain->domainname->name); |
2056 | } | 2069 | } |
2057 | tomoyo_read_unlock(idx); | 2070 | tomoyo_read_unlock(idx); |
2058 | if (tomoyo_profile_version != 20090903) | 2071 | if (tomoyo_profile_version != 20090903) { |
2072 | printk(KERN_ERR "You need to install userland programs for " | ||
2073 | "TOMOYO 2.3 and initialize policy configuration.\n"); | ||
2074 | printk(KERN_ERR "Please see http://tomoyo.sourceforge.jp/2.3/ " | ||
2075 | "for more information.\n"); | ||
2059 | panic("Profile version %u is not supported.\n", | 2076 | panic("Profile version %u is not supported.\n", |
2060 | tomoyo_profile_version); | 2077 | tomoyo_profile_version); |
2078 | } | ||
2061 | printk(KERN_INFO "TOMOYO: 2.3.0\n"); | 2079 | printk(KERN_INFO "TOMOYO: 2.3.0\n"); |
2062 | printk(KERN_INFO "Mandatory Access Control activated.\n"); | 2080 | printk(KERN_INFO "Mandatory Access Control activated.\n"); |
2063 | } | 2081 | } |