| .. | .. |
|---|
| 21 | 21 | { |
|---|
| 22 | 22 | const struct tomoyo_task_acl *acl = container_of(ptr, typeof(*acl), |
|---|
| 23 | 23 | head); |
|---|
| 24 | + |
|---|
| 24 | 25 | return !tomoyo_pathcmp(r->param.task.domainname, acl->domainname); |
|---|
| 25 | 26 | } |
|---|
| 26 | 27 | |
|---|
| .. | .. |
|---|
| 42 | 43 | { |
|---|
| 43 | 44 | char *data; |
|---|
| 44 | 45 | int error; |
|---|
| 46 | + |
|---|
| 45 | 47 | if (!count || count >= TOMOYO_EXEC_TMPSIZE - 10) |
|---|
| 46 | 48 | return -ENOMEM; |
|---|
| 47 | 49 | data = memdup_user_nul(buf, count); |
|---|
| .. | .. |
|---|
| 52 | 54 | const int idx = tomoyo_read_lock(); |
|---|
| 53 | 55 | struct tomoyo_path_info name; |
|---|
| 54 | 56 | struct tomoyo_request_info r; |
|---|
| 57 | + |
|---|
| 55 | 58 | name.name = data; |
|---|
| 56 | 59 | tomoyo_fill_path_info(&name); |
|---|
| 57 | 60 | /* Check "task manual_domain_transition" permission. */ |
|---|
| .. | .. |
|---|
| 67 | 70 | if (!new_domain) { |
|---|
| 68 | 71 | error = -ENOENT; |
|---|
| 69 | 72 | } else { |
|---|
| 70 | | - struct cred *cred = prepare_creds(); |
|---|
| 71 | | - if (!cred) { |
|---|
| 72 | | - error = -ENOMEM; |
|---|
| 73 | | - } else { |
|---|
| 74 | | - struct tomoyo_domain_info *old_domain = |
|---|
| 75 | | - cred->security; |
|---|
| 76 | | - cred->security = new_domain; |
|---|
| 77 | | - atomic_inc(&new_domain->users); |
|---|
| 78 | | - atomic_dec(&old_domain->users); |
|---|
| 79 | | - commit_creds(cred); |
|---|
| 80 | | - error = 0; |
|---|
| 81 | | - } |
|---|
| 73 | + struct tomoyo_task *s = tomoyo_task(current); |
|---|
| 74 | + struct tomoyo_domain_info *old_domain = |
|---|
| 75 | + s->domain_info; |
|---|
| 76 | + |
|---|
| 77 | + s->domain_info = new_domain; |
|---|
| 78 | + atomic_inc(&new_domain->users); |
|---|
| 79 | + atomic_dec(&old_domain->users); |
|---|
| 80 | + error = 0; |
|---|
| 82 | 81 | } |
|---|
| 83 | 82 | } |
|---|
| 84 | 83 | tomoyo_read_unlock(idx); |
|---|
| .. | .. |
|---|
| 104 | 103 | const char *domain = tomoyo_domain()->domainname->name; |
|---|
| 105 | 104 | loff_t len = strlen(domain); |
|---|
| 106 | 105 | loff_t pos = *ppos; |
|---|
| 106 | + |
|---|
| 107 | 107 | if (pos >= len || !count) |
|---|
| 108 | 108 | return 0; |
|---|
| 109 | 109 | len -= pos; |
|---|
| .. | .. |
|---|
| 234 | 234 | */ |
|---|
| 235 | 235 | static int __init tomoyo_initerface_init(void) |
|---|
| 236 | 236 | { |
|---|
| 237 | + struct tomoyo_domain_info *domain; |
|---|
| 237 | 238 | struct dentry *tomoyo_dir; |
|---|
| 238 | 239 | |
|---|
| 240 | + if (!tomoyo_enabled) |
|---|
| 241 | + return 0; |
|---|
| 242 | + domain = tomoyo_domain(); |
|---|
| 239 | 243 | /* Don't create securityfs entries unless registered. */ |
|---|
| 240 | | - if (current_cred()->security != &tomoyo_kernel_domain) |
|---|
| 244 | + if (domain != &tomoyo_kernel_domain) |
|---|
| 241 | 245 | return 0; |
|---|
| 242 | 246 | |
|---|
| 243 | 247 | tomoyo_dir = securityfs_create_dir("tomoyo", NULL); |
|---|