Merge branch 'for-torvalds' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[pandora-kernel.git] / security / tomoyo / common.c
index c668b44..a0d09e5 100644 (file)
@@ -108,10 +108,9 @@ static bool tomoyo_flush(struct tomoyo_io_buffer *head)
                        head->read_user_buf += len;
                        w += len;
                }
-               if (*w) {
-                       head->r.w[0] = w;
+               head->r.w[0] = w;
+               if (*w)
                        return false;
-               }
                /* Add '\0' for query. */
                if (head->poll) {
                        if (!head->read_user_buf_avail ||
@@ -459,8 +458,16 @@ static int tomoyo_write_profile(struct tomoyo_io_buffer *head)
        if (profile == &tomoyo_default_profile)
                return -EINVAL;
        if (!strcmp(data, "COMMENT")) {
-               const struct tomoyo_path_info *old_comment = profile->comment;
-               profile->comment = tomoyo_get_name(cp);
+               static DEFINE_SPINLOCK(lock);
+               const struct tomoyo_path_info *new_comment
+                       = tomoyo_get_name(cp);
+               const struct tomoyo_path_info *old_comment;
+               if (!new_comment)
+                       return -ENOMEM;
+               spin_lock(&lock);
+               old_comment = profile->comment;
+               profile->comment = new_comment;
+               spin_unlock(&lock);
                tomoyo_put_name(old_comment);
                return 0;
        }
@@ -768,8 +775,10 @@ static bool tomoyo_select_one(struct tomoyo_io_buffer *head, const char *data)
                return true; /* Do nothing if open(O_WRONLY). */
        memset(&head->r, 0, sizeof(head->r));
        head->r.print_this_domain_only = true;
-       head->r.eof = !domain;
-       head->r.domain = &domain->list;
+       if (domain)
+               head->r.domain = &domain->list;
+       else
+               head->r.eof = 1;
        tomoyo_io_printf(head, "# select %s\n", data);
        if (domain && domain->is_deleted)
                tomoyo_io_printf(head, "# This is a deleted domain.\n");
@@ -2051,13 +2060,22 @@ void tomoyo_check_profile(void)
                const u8 profile = domain->profile;
                if (tomoyo_profile_ptr[profile])
                        continue;
+               printk(KERN_ERR "You need to define profile %u before using it.\n",
+                      profile);
+               printk(KERN_ERR "Please see http://tomoyo.sourceforge.jp/2.3/ "
+                      "for more information.\n");
                panic("Profile %u (used by '%s') not defined.\n",
                      profile, domain->domainname->name);
        }
        tomoyo_read_unlock(idx);
-       if (tomoyo_profile_version != 20090903)
+       if (tomoyo_profile_version != 20090903) {
+               printk(KERN_ERR "You need to install userland programs for "
+                      "TOMOYO 2.3 and initialize policy configuration.\n");
+               printk(KERN_ERR "Please see http://tomoyo.sourceforge.jp/2.3/ "
+                      "for more information.\n");
                panic("Profile version %u is not supported.\n",
                      tomoyo_profile_version);
+       }
        printk(KERN_INFO "TOMOYO: 2.3.0\n");
        printk(KERN_INFO "Mandatory Access Control activated.\n");
 }