15 #include <linux/errno.h>
21 #include <linux/personality.h>
23 #include "include/audit.h"
44 for (i = 0; i < domain->
size; i++)
70 tracer = ptrace_parent(task);
74 tracerp = aa_cred_profile(cred);
112 perms.audit = perms.quiet = perms.kill = 0;
114 }
else if (!profile->file.dfa) {
116 }
else if ((ns == profile->ns)) {
126 aa_str_perms(profile->file.dfa, state, name, &cond, &perms);
145 static struct aa_profile *__attach_match(
const char *name,
185 profile = aa_get_profile(__attach_match(name, list));
212 static const char *separate_fqname(
const char *fqname,
const char **ns_name)
216 if (fqname[0] ==
':') {
221 *ns_name = fqname + 1;
222 name = *ns_name +
strlen(*ns_name) + 1;
233 static const char *next_name(
int xtype,
const char *name)
254 for (name = profile->
file.trans.table[index]; !new_profile && name;
255 name = next_name(xtype, name)) {
257 const char *xname =
NULL;
264 }
else if (*name ==
':') {
267 xname = name = separate_fqname(name, &ns_name);
270 xname = profile->
base.hname;
271 if (*ns_name ==
'@') {
279 }
else if (*name ==
'@') {
289 aa_put_namespace(new_ns);
307 const char *name,
u32 xindex)
318 if (xindex & AA_X_CHILD)
320 new_profile = find_attach(ns, &profile->
base.profiles,
324 new_profile = find_attach(ns, &ns->
base.profiles,
329 new_profile = x_table_lookup(profile, xindex);
352 bprm->
file->f_path.dentry->d_inode->i_uid,
353 bprm->
file->f_path.dentry->d_inode->i_mode
363 cxt = bprm->
cred->security;
366 profile = aa_get_profile(aa_newest_version(cxt->
profile));
372 state = profile->
file.start;
392 new_profile = aa_get_profile(cxt->
onexec);
394 new_profile = find_attach(ns, &ns->
base.profiles, name);
409 info =
"change_profile onexec";
417 state = aa_dfa_null_transition(profile->
file.dfa, state);
418 cp = change_profile_perms(profile, cxt->
onexec->ns,
424 new_profile = aa_get_profile(aa_newest_version(cxt->
onexec));
430 new_profile = x_to_profile(profile, name, perms.
xindex);
437 info =
"ix fallback";
438 new_profile = aa_get_profile(profile);
442 info =
"ux fallback";
445 info =
"profile not found";
453 info =
"could not create null profile";
456 target = new_profile->
base.hname;
468 aa_put_profile(new_profile);
482 error = may_change_ptraced_domain(
current, new_profile);
484 aa_put_profile(new_profile);
502 AA_DEBUG(
"scrubbing environment variables for %s profile=%s\n",
503 name, new_profile->
base.hname);
507 target = new_profile->
base.hname;
518 aa_put_profile(cxt->
onexec);
525 name, target, cond.
uid, info, error);
528 aa_put_profile(profile);
559 struct aa_profile *profile = __aa_current_profile();
563 if ((new_cxt->
profile == profile) ||
594 static char *new_compound_name(
const char *n1,
const char *n2)
598 sprintf(name,
"%s//%s", n1, n2);
618 const struct cred *cred;
637 cxt = cred->security;
638 profile = aa_cred_profile(cred);
653 for (i = 0; i < count && !hat; i++)
658 if (list_empty(&root->
base.profiles))
675 name = new_compound_name(root->
base.hname, hats[0]);
680 info =
"failed null profile create";
685 target = hat->
base.hname;
687 info =
"target not hat";
693 error = may_change_ptraced_domain(
current, hat);
705 else if (name && !error)
709 }
else if (previous_profile) {
713 target = previous_profile->
base.hname;
752 const struct cred *cred;
761 if (!hname && !ns_name)
773 cxt = cred->security;
774 profile = aa_cred_profile(cred);
794 info =
"namespace not found";
800 ns = aa_get_namespace(profile->
ns);
807 hname = profile->
base.hname;
810 perms = change_profile_perms(profile, ns, hname, request,
811 profile->
file.start);
812 if (!(perms.
allow & request)) {
820 info =
"profile not found";
827 info =
"failed null profile create";
834 error = may_change_ptraced_domain(
current, target);
836 info =
"ptrace prevents transition";
853 aa_put_namespace(ns);
854 aa_put_profile(target);