TOMOYO: Remove wrapper function for reading keyword.
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Wed, 16 Jun 2010 07:26:38 +0000 (16:26 +0900)
committerJames Morris <jmorris@namei.org>
Mon, 2 Aug 2010 05:34:34 +0000 (15:34 +1000)
Keyword strings are read-only. We can directly access them to reduce code size.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <jmorris@namei.org>
security/tomoyo/common.c
security/tomoyo/common.h
security/tomoyo/file.c

index 1a22fff89e70845b2a1d959d45f5bb5ba274cbbd..ba8360382895e1c2f3fcec3d08a60f214a0e2628 100644 (file)
@@ -812,7 +812,7 @@ static bool tomoyo_print_path_acl(struct tomoyo_io_buffer *head,
                        continue;
                pos = head->read_avail;
                if (!tomoyo_io_printf(head, "allow_%s ",
-                                     tomoyo_path2keyword(bit)) ||
+                                     tomoyo_path_keyword[bit]) ||
                    !tomoyo_print_name_union(head, &ptr->name) ||
                    !tomoyo_io_printf(head, "\n"))
                        goto out;
@@ -845,7 +845,7 @@ static bool tomoyo_print_path2_acl(struct tomoyo_io_buffer *head,
                        continue;
                pos = head->read_avail;
                if (!tomoyo_io_printf(head, "allow_%s ",
-                                     tomoyo_path22keyword(bit)) ||
+                                     tomoyo_path2_keyword[bit]) ||
                    !tomoyo_print_name_union(head, &ptr->name1) ||
                    !tomoyo_print_name_union(head, &ptr->name2) ||
                    !tomoyo_io_printf(head, "\n"))
@@ -879,7 +879,7 @@ static bool tomoyo_print_path_number_acl(struct tomoyo_io_buffer *head,
                        continue;
                pos = head->read_avail;
                if (!tomoyo_io_printf(head, "allow_%s",
-                                     tomoyo_path_number2keyword(bit)) ||
+                                     tomoyo_path_number_keyword[bit]) ||
                    !tomoyo_print_name_union(head, &ptr->name) ||
                    !tomoyo_print_number_union(head, &ptr->number) ||
                    !tomoyo_io_printf(head, "\n"))
@@ -913,7 +913,7 @@ static bool tomoyo_print_mkdev_acl(struct tomoyo_io_buffer *head,
                        continue;
                pos = head->read_avail;
                if (!tomoyo_io_printf(head, "allow_%s",
-                                     tomoyo_mkdev2keyword(bit)) ||
+                                     tomoyo_mkdev_keyword[bit]) ||
                    !tomoyo_print_name_union(head, &ptr->name) ||
                    !tomoyo_print_number_union(head, &ptr->mode) ||
                    !tomoyo_print_number_union(head, &ptr->major) ||
index 9b106e9adbec182cbd9c9444e32cc6a85c0b1d9e..f4da7a8034a3e4ee1f07d5edb11694c81440a9f3 100644 (file)
@@ -804,14 +804,8 @@ bool tomoyo_read_no_rewrite_policy(struct tomoyo_io_buffer *head);
 bool tomoyo_tokenize(char *buffer, char *w[], size_t size);
 /* Write domain policy violation warning message to console? */
 bool tomoyo_verbose_mode(const struct tomoyo_domain_info *domain);
-/* Convert double path operation to operation name. */
-const char *tomoyo_path22keyword(const u8 operation);
-const char *tomoyo_path_number2keyword(const u8 operation);
-const char *tomoyo_mkdev2keyword(const u8 operation);
 /* Get the last component of the given domainname. */
 const char *tomoyo_get_last_name(const struct tomoyo_domain_info *domain);
-/* Convert single path operation to operation name. */
-const char *tomoyo_path2keyword(const u8 operation);
 /* Fill "struct tomoyo_request_info". */
 int tomoyo_init_request_info(struct tomoyo_request_info *r,
                             struct tomoyo_domain_info *domain,
@@ -985,6 +979,11 @@ extern bool tomoyo_policy_loaded;
 /* The kernel's domain. */
 extern struct tomoyo_domain_info tomoyo_kernel_domain;
 
+extern const char *tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION];
+extern const char *tomoyo_mkdev_keyword[TOMOYO_MAX_MKDEV_OPERATION];
+extern const char *tomoyo_path2_keyword[TOMOYO_MAX_PATH2_OPERATION];
+extern const char *tomoyo_path_number_keyword[TOMOYO_MAX_PATH_NUMBER_OPERATION];
+
 extern unsigned int tomoyo_quota_for_query;
 extern unsigned int tomoyo_query_memory_size;
 
index 94e1493ab6b6e1c71be37f4089861ab659ef261f..67e65c7dde706aa3261f24d9302ca2769d9e4f41 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/slab.h>
 
 /* Keyword array for operations with one pathname. */
-static const char *tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION] = {
+const char *tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION] = {
        [TOMOYO_TYPE_READ_WRITE] = "read/write",
        [TOMOYO_TYPE_EXECUTE]    = "execute",
        [TOMOYO_TYPE_READ]       = "read",
@@ -25,22 +25,20 @@ static const char *tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION] = {
 };
 
 /* Keyword array for operations with one pathname and three numbers. */
-static const char *tomoyo_mkdev_keyword
-[TOMOYO_MAX_MKDEV_OPERATION] = {
+const char *tomoyo_mkdev_keyword[TOMOYO_MAX_MKDEV_OPERATION] = {
        [TOMOYO_TYPE_MKBLOCK]    = "mkblock",
        [TOMOYO_TYPE_MKCHAR]     = "mkchar",
 };
 
 /* Keyword array for operations with two pathnames. */
-static const char *tomoyo_path2_keyword[TOMOYO_MAX_PATH2_OPERATION] = {
+const char *tomoyo_path2_keyword[TOMOYO_MAX_PATH2_OPERATION] = {
        [TOMOYO_TYPE_LINK]       = "link",
        [TOMOYO_TYPE_RENAME]     = "rename",
        [TOMOYO_TYPE_PIVOT_ROOT] = "pivot_root",
 };
 
 /* Keyword array for operations with one pathname and one number. */
-static const char *tomoyo_path_number_keyword
-[TOMOYO_MAX_PATH_NUMBER_OPERATION] = {
+const char *tomoyo_path_number_keyword[TOMOYO_MAX_PATH_NUMBER_OPERATION] = {
        [TOMOYO_TYPE_CREATE]     = "create",
        [TOMOYO_TYPE_MKDIR]      = "mkdir",
        [TOMOYO_TYPE_MKFIFO]     = "mkfifo",
@@ -119,58 +117,6 @@ bool tomoyo_compare_number_union(const unsigned long value,
        return value >= ptr->values[0] && value <= ptr->values[1];
 }
 
-/**
- * tomoyo_path2keyword - Get the name of single path operation.
- *
- * @operation: Type of operation.
- *
- * Returns the name of single path operation.
- */
-const char *tomoyo_path2keyword(const u8 operation)
-{
-       return (operation < TOMOYO_MAX_PATH_OPERATION)
-               ? tomoyo_path_keyword[operation] : NULL;
-}
-
-/**
- * tomoyo_mkdev2keyword - Get the name of path/number/number/number operations.
- *
- * @operation: Type of operation.
- *
- * Returns the name of path/number/number/number operation.
- */
-const char *tomoyo_mkdev2keyword(const u8 operation)
-{
-       return (operation < TOMOYO_MAX_MKDEV_OPERATION)
-               ? tomoyo_mkdev_keyword[operation] : NULL;
-}
-
-/**
- * tomoyo_path22keyword - Get the name of double path operation.
- *
- * @operation: Type of operation.
- *
- * Returns the name of double path operation.
- */
-const char *tomoyo_path22keyword(const u8 operation)
-{
-       return (operation < TOMOYO_MAX_PATH2_OPERATION)
-               ? tomoyo_path2_keyword[operation] : NULL;
-}
-
-/**
- * tomoyo_path_number2keyword - Get the name of path/number operations.
- *
- * @operation: Type of operation.
- *
- * Returns the name of path/number operation.
- */
-const char *tomoyo_path_number2keyword(const u8 operation)
-{
-       return (operation < TOMOYO_MAX_PATH_NUMBER_OPERATION)
-               ? tomoyo_path_number_keyword[operation] : NULL;
-}
-
 static void tomoyo_add_slash(struct tomoyo_path_info *buf)
 {
        if (buf->is_dir)
@@ -266,8 +212,7 @@ static int tomoyo_audit_path2_log(struct tomoyo_request_info *r)
  */
 static int tomoyo_audit_mkdev_log(struct tomoyo_request_info *r)
 {
-       const char *operation = tomoyo_mkdev2keyword(r->param.mkdev.
-                                                           operation);
+       const char *operation = tomoyo_mkdev_keyword[r->param.mkdev.operation];
        const struct tomoyo_path_info *filename = r->param.mkdev.filename;
        const unsigned int major = r->param.mkdev.major;
        const unsigned int minor = r->param.mkdev.minor;