aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2011-06-26 10:22:59 -0400
committerJames Morris <jmorris@namei.org>2011-06-28 19:31:22 -0400
commit0e4ae0e0dec634b2ae53ac57d14141b140467dbe (patch)
tree9a3b46dd03ea21422359d3948514771d0cc9d72d /security
parentefe836ab2b514ae7b59528af36d452978b42d266 (diff)
TOMOYO: Make several options configurable.
To be able to start using enforcing mode from the early stage of boot sequence, this patch adds support for activating access control without calling external policy loader program. This will be useful for systems where operations which can lead to the hijacking of the boot sequence are needed before loading the policy. For example, you can activate immediately after loading the fixed part of policy which will allow only operations needed for mounting a partition which contains the variant part of policy and verifying (e.g. running GPG check) and loading the variant part of policy. Since you can start using enforcing mode from the beginning, you can reduce the possibility of hijacking the boot sequence. This patch makes several variables configurable on build time. This patch also adds TOMOYO_loader= and TOMOYO_trigger= kernel command line option to boot the same kernel in two different init systems (BSD-style init and systemd). Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security')
-rw-r--r--security/tomoyo/Kconfig61
-rw-r--r--security/tomoyo/common.c3
-rw-r--r--security/tomoyo/load_policy.c76
3 files changed, 117 insertions, 23 deletions
diff --git a/security/tomoyo/Kconfig b/security/tomoyo/Kconfig
index c8f385793235..7c7f8c16c10f 100644
--- a/security/tomoyo/Kconfig
+++ b/security/tomoyo/Kconfig
@@ -9,3 +9,64 @@ config SECURITY_TOMOYO
9 Required userspace tools and further information may be 9 Required userspace tools and further information may be
10 found at <http://tomoyo.sourceforge.jp/>. 10 found at <http://tomoyo.sourceforge.jp/>.
11 If you are unsure how to answer this question, answer N. 11 If you are unsure how to answer this question, answer N.
12
13config SECURITY_TOMOYO_MAX_ACCEPT_ENTRY
14 int "Default maximal count for learning mode"
15 default 2048
16 range 0 2147483647
17 depends on SECURITY_TOMOYO
18 help
19 This is the default value for maximal ACL entries
20 that are automatically appended into policy at "learning mode".
21 Some programs access thousands of objects, so running
22 such programs in "learning mode" dulls the system response
23 and consumes much memory.
24 This is the safeguard for such programs.
25
26config SECURITY_TOMOYO_MAX_AUDIT_LOG
27 int "Default maximal count for audit log"
28 default 1024
29 range 0 2147483647
30 depends on SECURITY_TOMOYO
31 help
32 This is the default value for maximal entries for
33 audit logs that the kernel can hold on memory.
34 You can read the log via /sys/kernel/security/tomoyo/audit.
35 If you don't need audit logs, you may set this value to 0.
36
37config SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
38 bool "Activate without calling userspace policy loader."
39 default n
40 depends on SECURITY_TOMOYO
41 ---help---
42 Say Y here if you want to activate access control as soon as built-in
43 policy was loaded. This option will be useful for systems where
44 operations which can lead to the hijacking of the boot sequence are
45 needed before loading the policy. For example, you can activate
46 immediately after loading the fixed part of policy which will allow
47 only operations needed for mounting a partition which contains the
48 variant part of policy and verifying (e.g. running GPG check) and
49 loading the variant part of policy. Since you can start using
50 enforcing mode from the beginning, you can reduce the possibility of
51 hijacking the boot sequence.
52
53config SECURITY_TOMOYO_POLICY_LOADER
54 string "Location of userspace policy loader"
55 default "/sbin/tomoyo-init"
56 depends on SECURITY_TOMOYO
57 depends on !SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
58 ---help---
59 This is the default pathname of policy loader which is called before
60 activation. You can override this setting via TOMOYO_loader= kernel
61 command line option.
62
63config SECURITY_TOMOYO_ACTIVATION_TRIGGER
64 string "Trigger for calling userspace policy loader"
65 default "/sbin/init"
66 depends on SECURITY_TOMOYO
67 depends on !SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
68 ---help---
69 This is the default pathname of activation trigger.
70 You can override this setting via TOMOYO_trigger= kernel command line
71 option. For example, if you pass init=/bin/systemd option, you may
72 want to also pass TOMOYO_trigger=/bin/systemd option.
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index 01e60ad68b3a..8b14cef2338d 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -2420,4 +2420,7 @@ void __init tomoyo_load_builtin_policy(void)
2420 } 2420 }
2421 } 2421 }
2422 tomoyo_read_unlock(idx); 2422 tomoyo_read_unlock(idx);
2423#ifdef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
2424 tomoyo_check_profile();
2425#endif
2423} 2426}
diff --git a/security/tomoyo/load_policy.c b/security/tomoyo/load_policy.c
index 3312e5624f24..6a5463d26635 100644
--- a/security/tomoyo/load_policy.c
+++ b/security/tomoyo/load_policy.c
@@ -8,8 +8,27 @@
8 8
9#include "common.h" 9#include "common.h"
10 10
11/* path to policy loader */ 11#ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
12static const char *tomoyo_loader = "/sbin/tomoyo-init"; 12
13/*
14 * Path to the policy loader. (default = CONFIG_SECURITY_TOMOYO_POLICY_LOADER)
15 */
16static const char *tomoyo_loader;
17
18/**
19 * tomoyo_loader_setup - Set policy loader.
20 *
21 * @str: Program to use as a policy loader (e.g. /sbin/tomoyo-init ).
22 *
23 * Returns 0.
24 */
25static int __init tomoyo_loader_setup(char *str)
26{
27 tomoyo_loader = str;
28 return 0;
29}
30
31__setup("TOMOYO_loader=", tomoyo_loader_setup);
13 32
14/** 33/**
15 * tomoyo_policy_loader_exists - Check whether /sbin/tomoyo-init exists. 34 * tomoyo_policy_loader_exists - Check whether /sbin/tomoyo-init exists.
@@ -18,24 +37,38 @@ static const char *tomoyo_loader = "/sbin/tomoyo-init";
18 */ 37 */
19static bool tomoyo_policy_loader_exists(void) 38static bool tomoyo_policy_loader_exists(void)
20{ 39{
21 /*
22 * Don't activate MAC if the policy loader doesn't exist.
23 * If the initrd includes /sbin/init but real-root-dev has not
24 * mounted on / yet, activating MAC will block the system since
25 * policies are not loaded yet.
26 * Thus, let do_execve() call this function every time.
27 */
28 struct path path; 40 struct path path;
29 41 if (!tomoyo_loader)
42 tomoyo_loader = CONFIG_SECURITY_TOMOYO_POLICY_LOADER;
30 if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) { 43 if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) {
31 printk(KERN_INFO "Not activating Mandatory Access Control now " 44 printk(KERN_INFO "Not activating Mandatory Access Control "
32 "since %s doesn't exist.\n", tomoyo_loader); 45 "as %s does not exist.\n", tomoyo_loader);
33 return false; 46 return false;
34 } 47 }
35 path_put(&path); 48 path_put(&path);
36 return true; 49 return true;
37} 50}
38 51
52/*
53 * Path to the trigger. (default = CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER)
54 */
55static const char *tomoyo_trigger;
56
57/**
58 * tomoyo_trigger_setup - Set trigger for activation.
59 *
60 * @str: Program to use as an activation trigger (e.g. /sbin/init ).
61 *
62 * Returns 0.
63 */
64static int __init tomoyo_trigger_setup(char *str)
65{
66 tomoyo_trigger = str;
67 return 0;
68}
69
70__setup("TOMOYO_trigger=", tomoyo_trigger_setup);
71
39/** 72/**
40 * tomoyo_load_policy - Run external policy loader to load policy. 73 * tomoyo_load_policy - Run external policy loader to load policy.
41 * 74 *
@@ -51,24 +84,19 @@ static bool tomoyo_policy_loader_exists(void)
51 */ 84 */
52void tomoyo_load_policy(const char *filename) 85void tomoyo_load_policy(const char *filename)
53{ 86{
87 static bool done;
54 char *argv[2]; 88 char *argv[2];
55 char *envp[3]; 89 char *envp[3];
56 90
57 if (tomoyo_policy_loaded) 91 if (tomoyo_policy_loaded || done)
58 return; 92 return;
59 /* 93 if (!tomoyo_trigger)
60 * Check filename is /sbin/init or /sbin/tomoyo-start. 94 tomoyo_trigger = CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER;
61 * /sbin/tomoyo-start is a dummy filename in case where /sbin/init can't 95 if (strcmp(filename, tomoyo_trigger))
62 * be passed.
63 * You can create /sbin/tomoyo-start by
64 * "ln -s /bin/true /sbin/tomoyo-start".
65 */
66 if (strcmp(filename, "/sbin/init") &&
67 strcmp(filename, "/sbin/tomoyo-start"))
68 return; 96 return;
69 if (!tomoyo_policy_loader_exists()) 97 if (!tomoyo_policy_loader_exists())
70 return; 98 return;
71 99 done = true;
72 printk(KERN_INFO "Calling %s to load policy. Please wait.\n", 100 printk(KERN_INFO "Calling %s to load policy. Please wait.\n",
73 tomoyo_loader); 101 tomoyo_loader);
74 argv[0] = (char *) tomoyo_loader; 102 argv[0] = (char *) tomoyo_loader;
@@ -79,3 +107,5 @@ void tomoyo_load_policy(const char *filename)
79 call_usermodehelper(argv[0], argv, envp, 1); 107 call_usermodehelper(argv[0], argv, envp, 1);
80 tomoyo_check_profile(); 108 tomoyo_check_profile();
81} 109}
110
111#endif