8 #include <linux/binfmts.h>
9 #include <linux/slab.h>
41 list_for_each_entry_rcu(entry, list, list) {
44 if (!check_duplicate(entry, new_entry))
53 list_add_tail_rcu(&entry->
list, list);
103 if (param->
data[0]) {
105 if (!new_entry->
cond)
111 if (new_entry->
cond->transit &&
119 list_for_each_entry_rcu(entry, list, list) {
122 if (!tomoyo_same_acl_head(entry, new_entry) ||
123 !check_duplicate(entry, new_entry))
126 entry->
is_deleted = merge_duplicate(entry, new_entry,
133 if (error && !is_delete) {
136 list_add_tail_rcu(&entry->
list, list);
142 tomoyo_put_condition(new_entry->
cond);
162 bool retried =
false;
166 list_for_each_entry_rcu(ptr, list, list) {
169 if (!check_entry(r, ptr))
179 list = &domain->
ns->acl_group[domain->
group];
195 static const char *tomoyo_last_word(
const char *
name)
248 if (program &&
strcmp(program,
"any")) {
255 if (domainname &&
strcmp(domainname,
"any")) {
267 tomoyo_same_transition_control);
287 static inline bool tomoyo_scan_transition
293 list_for_each_entry_rcu(ptr, list,
head.list) {
294 if (ptr->
head.is_deleted || ptr->
type != type)
336 const char *last_name = tomoyo_last_word(domainname->
name);
341 if (!tomoyo_scan_transition(list, domainname, program,
404 tomoyo_same_aggregator);
423 (
const char *name,
const unsigned int len)
428 (name[len] && name[len] !=
' '))
449 const char *cp = domainname;
450 unsigned int len = 0;
451 while (*cp && *cp++ !=
' ')
453 ptr = tomoyo_find_namespace(domainname, len);
458 entry = kzalloc(
sizeof(*entry) + len + 1,
GFP_NOFS);
463 ptr = tomoyo_find_namespace(domainname, len);
465 char *name = (
char *) (entry + 1);
467 memmove(name, domainname, len);
486 static bool tomoyo_namespace_jump(
const char *domainname)
488 const char *
namespace = tomoyo_current_namespace()->name;
489 const int len =
strlen(
namespace);
490 return strncmp(domainname,
namespace, len) ||
491 (domainname[len] && domainname[len] !=
' ');
534 if (transit && tomoyo_namespace_jump(domainname))
566 if (entry && transit) {
596 unsigned long pos = bprm->
p;
598 int argv_count = bprm->
argc;
599 int envp_count = bprm->
envc;
603 ee->
r.profile = r->
domain->profile;
606 if (!r->
mode || !envp_count)
611 while (error == -
ENOMEM) {
616 while (argv_count && offset <
PAGE_SIZE) {
617 if (!env_page.
data[offset++])
625 const unsigned char c = env_page.
data[offset++];
629 arg_ptr[arg_len++] =
'\0';
630 }
else if (c ==
'\\') {
631 arg_ptr[arg_len++] =
'\\';
632 arg_ptr[arg_len++] =
'\\';
633 }
else if (c >
' ' && c < 127) {
634 arg_ptr[arg_len++] =
c;
636 arg_ptr[arg_len++] =
'\\';
637 arg_ptr[arg_len++] = (c >> 6) +
'0';
639 = ((c >> 3) & 7) +
'0';
640 arg_ptr[arg_len++] = (c & 7) +
'0';
643 arg_ptr[arg_len] =
'\0';
680 const char *original_name = bprm->
filename;
682 bool reject_on_transition_failure =
false;
698 ee->
r.obj = &ee->
obj;
699 ee->
obj.path1 = bprm->
file->f_path;
713 candidate = &exename;
714 list_for_each_entry_rcu(ptr, list,
head.list) {
715 if (ptr->
head.is_deleted ||
736 if (ee->
r.param.path.matched_path)
737 candidate = ee->
r.param.path.matched_path;
746 const char *domainname = ee->
transition->name;
747 reject_on_transition_failure =
true;
748 if (!
strcmp(domainname,
"keep"))
749 goto force_keep_domain;
750 if (!
strcmp(domainname,
"child"))
751 goto force_child_domain;
752 if (!
strcmp(domainname,
"reset"))
753 goto force_reset_domain;
754 if (!
strcmp(domainname,
"initialize"))
755 goto force_initialize_domain;
756 if (!
strcmp(domainname,
"parent")) {
763 }
else if (*domainname ==
'<')
768 goto force_jump_domain;
785 reject_on_transition_failure =
true;
788 force_initialize_domain:
791 old_domain->
ns->name, candidate->
name);
821 else if (reject_on_transition_failure) {
831 ee->
r.granted =
false;
835 "ERROR: Domain '%s' not defined.\n", ee->
tmp);
843 bprm->
cred->security = domain;
846 ee->
r.domain = domain;
847 retval = tomoyo_environ(ee);
882 if (page != dump->
page) {
883 const unsigned int offset = pos %
PAGE_SIZE;