Lines Matching refs:profile

87 static inline aa_state_t match_component(struct aa_profile *profile,  in match_component()  argument
91 struct aa_ruleset *rules = list_first_entry(&profile->rules, in match_component()
97 if (profile->ns == tp->ns) in match_component()
101 ns_name = aa_ns_name(profile->ns, tp->ns, true); in match_component()
124 static int label_compound_match(struct aa_profile *profile, in label_compound_match() argument
129 struct aa_ruleset *rules = list_first_entry(&profile->rules, in label_compound_match()
137 if (!aa_ns_visible(profile->ns, tp->ns, subns)) in label_compound_match()
139 state = match_component(profile, tp, stack, state); in label_compound_match()
151 if (!aa_ns_visible(profile->ns, tp->ns, subns)) in label_compound_match()
154 state = match_component(profile, tp, false, state); in label_compound_match()
159 aa_apply_modes_to_perms(profile, perms); in label_compound_match()
186 static int label_components_match(struct aa_profile *profile, in label_components_match() argument
191 struct aa_ruleset *rules = list_first_entry(&profile->rules, in label_components_match()
201 if (!aa_ns_visible(profile->ns, tp->ns, subns)) in label_components_match()
203 state = match_component(profile, tp, stack, start); in label_components_match()
214 aa_apply_modes_to_perms(profile, &tmp); in label_components_match()
217 if (!aa_ns_visible(profile->ns, tp->ns, subns)) in label_components_match()
219 state = match_component(profile, tp, stack, start); in label_components_match()
223 aa_apply_modes_to_perms(profile, &tmp); in label_components_match()
249 static int label_match(struct aa_profile *profile, struct aa_label *label, in label_match() argument
256 error = label_compound_match(profile, label, stack, state, subns, in label_match()
262 return label_components_match(profile, label, stack, state, subns, in label_match()
283 static int change_profile_perms(struct aa_profile *profile, in change_profile_perms() argument
288 if (profile_unconfined(profile)) { in change_profile_perms()
295 return label_match(profile, target, stack, start, true, request, perms); in change_profile_perms()
307 struct aa_profile *profile, aa_state_t state) in aa_xattrs_match() argument
312 struct aa_attachment *attach = &profile->attach; in aa_xattrs_match()
391 struct aa_profile *profile, *candidate = NULL; in find_attach() local
398 list_for_each_entry_rcu(profile, head, base.list) { in find_attach()
399 struct aa_attachment *attach = &profile->attach; in find_attach()
401 if (profile->label.flags & FLAG_NULL && in find_attach()
402 &profile->label == ns_unconfined(profile->ns)) in find_attach()
436 if (!aa_get_profile_not0(profile)) in find_attach()
439 ret = aa_xattrs_match(bprm, profile, in find_attach()
442 aa_put_profile(profile); in find_attach()
471 candidate = profile; in find_attach()
476 } else if (!strcmp(profile->base.name, name)) { in find_attach()
481 candidate = profile; in find_attach()
513 struct aa_label *x_table_lookup(struct aa_profile *profile, u32 xindex, in x_table_lookup() argument
516 struct aa_ruleset *rules = list_first_entry(&profile->rules, in x_table_lookup()
533 new_profile = aa_find_child(profile, *name); in x_table_lookup()
538 label = aa_label_parse(&profile->label, *name, GFP_KERNEL, in x_table_lookup()
562 static struct aa_label *x_to_label(struct aa_profile *profile, in x_to_label() argument
568 struct aa_ruleset *rules = list_first_entry(&profile->rules, in x_to_label()
571 struct aa_ns *ns = profile->ns; in x_to_label()
585 new = x_table_lookup(profile, xindex, lookupname); in x_to_label()
593 new = find_attach(bprm, ns, &profile->base.profiles, in x_to_label()
610 new = aa_get_newest_label(&profile->label); in x_to_label()
612 new = aa_get_newest_label(ns_unconfined(profile->ns)); in x_to_label()
632 struct aa_profile *profile, in profile_transition() argument
637 struct aa_ruleset *rules = list_first_entry(&profile->rules, in profile_transition()
646 AA_BUG(!profile); in profile_transition()
650 error = aa_path_name(&bprm->file->f_path, profile->path_flags, buffer, in profile_transition()
651 &name, &info, profile->disconnected); in profile_transition()
653 if (profile_unconfined(profile) || in profile_transition()
654 (profile->label.flags & FLAG_IX_ON_NAME_ERROR)) { in profile_transition()
657 new = aa_get_newest_label(&profile->label); in profile_transition()
663 if (profile_unconfined(profile)) { in profile_transition()
664 new = find_attach(bprm, profile->ns, in profile_transition()
665 &profile->ns->base.profiles, name, &info); in profile_transition()
671 return aa_get_newest_label(&profile->label); in profile_transition()
678 new = x_to_label(profile, bprm, name, perms.xindex, &target, in profile_transition()
680 if (new && new->proxy == profile->label.proxy && info) { in profile_transition()
689 } else if (COMPLAIN_MODE(profile)) { in profile_transition()
693 new_profile = aa_new_learning_profile(profile, false, name, in profile_transition()
722 aa_audit_file(subj_cred, profile, &perms, OP_EXEC, MAY_EXEC, name, in profile_transition()
734 struct aa_profile *profile, struct aa_label *onexec, in profile_onexec() argument
739 struct aa_ruleset *rules = list_first_entry(&profile->rules, in profile_onexec()
746 AA_BUG(!profile); in profile_onexec()
751 if (profile_unconfined(profile)) { in profile_onexec()
761 error = aa_path_name(&bprm->file->f_path, profile->path_flags, buffer, in profile_onexec()
762 &xname, &info, profile->disconnected); in profile_onexec()
764 if (profile_unconfined(profile) || in profile_onexec()
765 (profile->label.flags & FLAG_IX_ON_NAME_ERROR)) { in profile_onexec()
784 error = change_profile_perms(profile, onexec, stack, AA_MAY_ONEXEC, in profile_onexec()
802 return aa_audit_file(subj_cred, profile, &perms, OP_EXEC, in profile_onexec()
816 struct aa_profile *profile; in handle_onexec() local
826 error = fn_for_each_in_ns(label, profile, in handle_onexec()
827 profile_onexec(subj_cred, profile, onexec, stack, in handle_onexec()
831 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in handle_onexec()
833 profile_transition(subj_cred, profile, bprm, in handle_onexec()
839 error = fn_for_each_in_ns(label, profile, in handle_onexec()
840 profile_onexec(subj_cred, profile, onexec, stack, bprm, in handle_onexec()
844 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in handle_onexec()
845 aa_label_merge(&profile->label, onexec, in handle_onexec()
847 profile_transition(subj_cred, profile, bprm, in handle_onexec()
856 error = fn_for_each_in_ns(label, profile, in handle_onexec()
857 aa_audit_file(subj_cred, profile, &nullperms, in handle_onexec()
878 struct aa_profile *profile; in apparmor_bprm_creds_for_exec() local
920 new = fn_label_build(label, profile, GFP_KERNEL, in apparmor_bprm_creds_for_exec()
921 profile_transition(subj_cred, profile, bprm, in apparmor_bprm_creds_for_exec()
993 error = fn_for_each(label, profile, in apparmor_bprm_creds_for_exec()
994 aa_audit_file(current_cred(), profile, &nullperms, in apparmor_bprm_creds_for_exec()
1012 struct aa_profile *profile, in build_change_hat() argument
1019 if (sibling && PROFILE_IS_HAT(profile)) { in build_change_hat()
1020 root = aa_get_profile_rcu(&profile->parent); in build_change_hat()
1021 } else if (!sibling && !PROFILE_IS_HAT(profile)) { in build_change_hat()
1022 root = aa_get_profile(profile); in build_change_hat()
1032 if (COMPLAIN_MODE(profile)) { in build_change_hat()
1033 hat = aa_new_learning_profile(profile, true, name, in build_change_hat()
1044 aa_audit_file(subj_cred, profile, &nullperms, OP_CHANGE_HAT, in build_change_hat()
1065 struct aa_profile *profile, *root, *hat = NULL; in change_hat() local
1082 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1083 if (sibling && PROFILE_IS_HAT(profile)) { in change_hat()
1084 root = aa_get_profile_rcu(&profile->parent); in change_hat()
1085 } else if (!sibling && !PROFILE_IS_HAT(profile)) { in change_hat()
1086 root = aa_get_profile(profile); in change_hat()
1095 if (!COMPLAIN_MODE(profile)) in change_hat()
1118 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1119 if (!list_empty(&profile->base.profiles)) { in change_hat()
1129 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1137 if (count > 1 || COMPLAIN_MODE(profile)) { in change_hat()
1138 aa_audit_file(subj_cred, profile, &nullperms, in change_hat()
1147 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in change_hat()
1148 build_change_hat(subj_cred, profile, name, in change_hat()
1150 aa_get_label(&profile->label)); in change_hat()
1182 struct aa_profile *profile; in aa_change_hat() local
1281 fn_for_each_in_ns(label, profile, in aa_change_hat()
1282 aa_audit_file(subj_cred, profile, &perms, OP_CHANGE_HAT, in aa_change_hat()
1292 struct aa_profile *profile, in change_profile_perms_wrapper() argument
1296 struct aa_ruleset *rules = list_first_entry(&profile->rules, in change_profile_perms_wrapper()
1302 error = change_profile_perms(profile, target, stack, request, in change_profile_perms_wrapper()
1306 error = aa_audit_file(subj_cred, profile, perms, op, request, in change_profile_perms_wrapper()
1332 struct aa_profile *profile; in aa_change_profile() local
1390 (void) fn_for_each_in_ns(label, profile, in aa_change_profile()
1391 aa_audit_file(subj_cred, profile, &perms, op, in aa_change_profile()
1436 error = fn_for_each_in_ns(label, profile, in aa_change_profile()
1439 profile, target, stack, in aa_change_profile()
1450 if (error && !fn_for_each_in_ns(label, profile, in aa_change_profile()
1451 COMPLAIN_MODE(profile))) in aa_change_profile()
1466 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in aa_change_profile()
1468 aa_get_label(&profile->label)); in aa_change_profile()
1508 error = fn_for_each_in_ns(label, profile, in aa_change_profile()
1510 profile, &perms, op, request, auditname, in aa_change_profile()