aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/tomoyo.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/tomoyo/tomoyo.c')
-rw-r--r--security/tomoyo/tomoyo.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
index ad9555fc3765..714daa34d493 100644
--- a/security/tomoyo/tomoyo.c
+++ b/security/tomoyo/tomoyo.c
@@ -76,8 +76,18 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm)
76 * Execute permission is checked against pathname passed to do_execve() 76 * Execute permission is checked against pathname passed to do_execve()
77 * using current domain. 77 * using current domain.
78 */ 78 */
79 if (!domain) 79 if (!domain) {
80 return tomoyo_find_next_domain(bprm); 80 /*
81 * We will need to protect whole execve() operation when GC
82 * starts kfree()ing "struct tomoyo_domain_info" because
83 * bprm->cred->security points to "struct tomoyo_domain_info"
84 * but "struct tomoyo_domain_info" does not have a refcounter.
85 */
86 const int idx = tomoyo_read_lock();
87 const int err = tomoyo_find_next_domain(bprm);
88 tomoyo_read_unlock(idx);
89 return err;
90 }
81 /* 91 /*
82 * Read permission is checked against interpreters using next domain. 92 * Read permission is checked against interpreters using next domain.
83 * '1' is the result of open_to_namei_flags(O_RDONLY). 93 * '1' is the result of open_to_namei_flags(O_RDONLY).
@@ -278,6 +288,9 @@ static struct security_operations tomoyo_security_ops = {
278 .sb_pivotroot = tomoyo_sb_pivotroot, 288 .sb_pivotroot = tomoyo_sb_pivotroot,
279}; 289};
280 290
291/* Lock for GC. */
292struct srcu_struct tomoyo_ss;
293
281static int __init tomoyo_init(void) 294static int __init tomoyo_init(void)
282{ 295{
283 struct cred *cred = (struct cred *) current_cred(); 296 struct cred *cred = (struct cred *) current_cred();
@@ -285,7 +298,8 @@ static int __init tomoyo_init(void)
285 if (!security_module_enable(&tomoyo_security_ops)) 298 if (!security_module_enable(&tomoyo_security_ops))
286 return 0; 299 return 0;
287 /* register ourselves with the security framework */ 300 /* register ourselves with the security framework */
288 if (register_security(&tomoyo_security_ops)) 301 if (register_security(&tomoyo_security_ops) ||
302 init_srcu_struct(&tomoyo_ss))
289 panic("Failure registering TOMOYO Linux"); 303 panic("Failure registering TOMOYO Linux");
290 printk(KERN_INFO "TOMOYO Linux initialized\n"); 304 printk(KERN_INFO "TOMOYO Linux initialized\n");
291 cred->security = &tomoyo_kernel_domain; 305 cred->security = &tomoyo_kernel_domain;