Lines Matching refs:profile

99 static inline unsigned int match_component(struct aa_profile *profile,  in match_component()  argument
106 state = aa_dfa_match(profile->file.dfa, state, "&"); in match_component()
107 if (profile->ns == tp->ns) in match_component()
108 return aa_dfa_match(profile->file.dfa, state, tp->base.hname); in match_component()
111 ns_name = aa_ns_name(profile->ns, tp->ns, true); in match_component()
112 state = aa_dfa_match_len(profile->file.dfa, state, ":", 1); in match_component()
113 state = aa_dfa_match(profile->file.dfa, state, ns_name); in match_component()
114 state = aa_dfa_match_len(profile->file.dfa, state, ":", 1); in match_component()
115 return aa_dfa_match(profile->file.dfa, state, tp->base.hname); in match_component()
134 static int label_compound_match(struct aa_profile *profile, in label_compound_match() argument
145 if (!aa_ns_visible(profile->ns, tp->ns, subns)) in label_compound_match()
147 state = match_component(profile, tp, stack, state); in label_compound_match()
159 if (!aa_ns_visible(profile->ns, tp->ns, subns)) in label_compound_match()
161 state = aa_dfa_match(profile->file.dfa, state, "//&"); in label_compound_match()
162 state = match_component(profile, tp, false, state); in label_compound_match()
166 *perms = aa_compute_fperms(profile->file.dfa, state, &cond); in label_compound_match()
167 aa_apply_modes_to_perms(profile, perms); in label_compound_match()
194 static int label_components_match(struct aa_profile *profile, in label_components_match() argument
207 if (!aa_ns_visible(profile->ns, tp->ns, subns)) in label_components_match()
209 state = match_component(profile, tp, stack, start); in label_components_match()
219 tmp = aa_compute_fperms(profile->file.dfa, state, &cond); in label_components_match()
220 aa_apply_modes_to_perms(profile, &tmp); in label_components_match()
223 if (!aa_ns_visible(profile->ns, tp->ns, subns)) in label_components_match()
225 state = match_component(profile, tp, stack, start); in label_components_match()
228 tmp = aa_compute_fperms(profile->file.dfa, state, &cond); in label_components_match()
229 aa_apply_modes_to_perms(profile, &tmp); in label_components_match()
255 static int label_match(struct aa_profile *profile, struct aa_label *label, in label_match() argument
262 error = label_compound_match(profile, label, stack, state, subns, in label_match()
268 return label_components_match(profile, label, stack, state, subns, in label_match()
288 static int change_profile_perms(struct aa_profile *profile, in change_profile_perms() argument
293 if (profile_unconfined(profile)) { in change_profile_perms()
300 return label_match(profile, target, stack, start, true, request, perms); in change_profile_perms()
312 struct aa_profile *profile, unsigned int state) in aa_xattrs_match() argument
318 int value_size = 0, ret = profile->xattr_count; in aa_xattrs_match()
320 if (!bprm || !profile->xattr_count) in aa_xattrs_match()
325 state = aa_dfa_outofband_transition(profile->xmatch, state); in aa_xattrs_match()
328 for (i = 0; i < profile->xattr_count; i++) { in aa_xattrs_match()
329 size = vfs_getxattr_alloc(&init_user_ns, d, profile->xattrs[i], in aa_xattrs_match()
339 state = aa_dfa_null_transition(profile->xmatch, state); in aa_xattrs_match()
341 state = aa_dfa_match_len(profile->xmatch, state, value, in aa_xattrs_match()
343 perm = dfa_user_allow(profile->xmatch, state); in aa_xattrs_match()
350 state = aa_dfa_outofband_transition(profile->xmatch, state); in aa_xattrs_match()
394 struct aa_profile *profile, *candidate = NULL; in find_attach() local
401 list_for_each_entry_rcu(profile, head, base.list) { in find_attach()
402 if (profile->label.flags & FLAG_NULL && in find_attach()
403 &profile->label == ns_unconfined(profile->ns)) in find_attach()
417 if (profile->xmatch) { in find_attach()
421 state = aa_dfa_leftmatch(profile->xmatch, DFA_START, in find_attach()
423 perm = dfa_user_allow(profile->xmatch, state); in find_attach()
431 if (bprm && profile->xattr_count) { in find_attach()
434 if (!aa_get_profile_not0(profile)) in find_attach()
437 ret = aa_xattrs_match(bprm, profile, in find_attach()
440 aa_put_profile(profile); in find_attach()
469 candidate = profile; in find_attach()
470 candidate_len = profile->xmatch_len; in find_attach()
474 } else if (!strcmp(profile->base.name, name)) { in find_attach()
479 candidate = profile; in find_attach()
511 struct aa_label *x_table_lookup(struct aa_profile *profile, u32 xindex, in x_table_lookup() argument
524 for (*name = profile->file.trans.table[index]; !label && *name; in x_table_lookup()
529 new_profile = aa_find_child(profile, *name); in x_table_lookup()
534 label = aa_label_parse(&profile->label, *name, GFP_KERNEL, in x_table_lookup()
557 static struct aa_label *x_to_label(struct aa_profile *profile, in x_to_label() argument
564 struct aa_ns *ns = profile->ns; in x_to_label()
575 stack = profile->file.trans.table[xindex & AA_X_INDEX_MASK]; in x_to_label()
578 new = x_table_lookup(profile, xindex, lookupname); in x_to_label()
586 new = find_attach(bprm, ns, &profile->base.profiles, in x_to_label()
603 new = aa_get_newest_label(&profile->label); in x_to_label()
605 new = aa_get_newest_label(ns_unconfined(profile->ns)); in x_to_label()
624 static struct aa_label *profile_transition(struct aa_profile *profile, in profile_transition() argument
631 unsigned int state = profile->file.start; in profile_transition()
636 AA_BUG(!profile); in profile_transition()
640 error = aa_path_name(&bprm->file->f_path, profile->path_flags, buffer, in profile_transition()
641 &name, &info, profile->disconnected); in profile_transition()
643 if (profile_unconfined(profile) || in profile_transition()
644 (profile->label.flags & FLAG_IX_ON_NAME_ERROR)) { in profile_transition()
647 new = aa_get_newest_label(&profile->label); in profile_transition()
653 if (profile_unconfined(profile)) { in profile_transition()
654 new = find_attach(bprm, profile->ns, in profile_transition()
655 &profile->ns->base.profiles, name, &info); in profile_transition()
661 return aa_get_newest_label(&profile->label); in profile_transition()
665 state = aa_str_perms(profile->file.dfa, state, name, cond, &perms); in profile_transition()
668 new = x_to_label(profile, bprm, name, perms.xindex, &target, in profile_transition()
670 if (new && new->proxy == profile->label.proxy && info) { in profile_transition()
679 } else if (COMPLAIN_MODE(profile)) { in profile_transition()
683 new_profile = aa_new_null_profile(profile, false, name, in profile_transition()
712 aa_audit_file(profile, &perms, OP_EXEC, MAY_EXEC, name, target, new, in profile_transition()
722 static int profile_onexec(struct aa_profile *profile, struct aa_label *onexec, in profile_onexec() argument
727 unsigned int state = profile->file.start; in profile_onexec()
732 AA_BUG(!profile); in profile_onexec()
737 if (profile_unconfined(profile)) { in profile_onexec()
747 error = aa_path_name(&bprm->file->f_path, profile->path_flags, buffer, in profile_onexec()
748 &xname, &info, profile->disconnected); in profile_onexec()
750 if (profile_unconfined(profile) || in profile_onexec()
751 (profile->label.flags & FLAG_IX_ON_NAME_ERROR)) { in profile_onexec()
760 state = aa_str_perms(profile->file.dfa, state, xname, cond, &perms); in profile_onexec()
769 state = aa_dfa_null_transition(profile->file.dfa, state); in profile_onexec()
770 error = change_profile_perms(profile, onexec, stack, AA_MAY_ONEXEC, in profile_onexec()
788 return aa_audit_file(profile, &perms, OP_EXEC, AA_MAY_ONEXEC, xname, in profile_onexec()
800 struct aa_profile *profile; in handle_onexec() local
810 error = fn_for_each_in_ns(label, profile, in handle_onexec()
811 profile_onexec(profile, onexec, stack, in handle_onexec()
815 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in handle_onexec()
817 profile_transition(profile, bprm, buffer, in handle_onexec()
822 error = fn_for_each_in_ns(label, profile, in handle_onexec()
823 profile_onexec(profile, onexec, stack, bprm, in handle_onexec()
827 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in handle_onexec()
828 aa_label_merge(&profile->label, onexec, in handle_onexec()
830 profile_transition(profile, bprm, buffer, in handle_onexec()
838 error = fn_for_each_in_ns(label, profile, in handle_onexec()
839 aa_audit_file(profile, &nullperms, OP_CHANGE_ONEXEC, in handle_onexec()
858 struct aa_profile *profile; in apparmor_bprm_creds_for_exec() local
899 new = fn_label_build(label, profile, GFP_KERNEL, in apparmor_bprm_creds_for_exec()
900 profile_transition(profile, bprm, buffer, in apparmor_bprm_creds_for_exec()
971 error = fn_for_each(label, profile, in apparmor_bprm_creds_for_exec()
972 aa_audit_file(profile, &nullperms, OP_EXEC, MAY_EXEC, in apparmor_bprm_creds_for_exec()
988 static struct aa_label *build_change_hat(struct aa_profile *profile, in build_change_hat() argument
995 if (sibling && PROFILE_IS_HAT(profile)) { in build_change_hat()
996 root = aa_get_profile_rcu(&profile->parent); in build_change_hat()
997 } else if (!sibling && !PROFILE_IS_HAT(profile)) { in build_change_hat()
998 root = aa_get_profile(profile); in build_change_hat()
1008 if (COMPLAIN_MODE(profile)) { in build_change_hat()
1009 hat = aa_new_null_profile(profile, true, name, in build_change_hat()
1020 aa_audit_file(profile, &nullperms, OP_CHANGE_HAT, AA_MAY_CHANGEHAT, in build_change_hat()
1039 struct aa_profile *profile, *root, *hat = NULL; in change_hat() local
1056 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1057 if (sibling && PROFILE_IS_HAT(profile)) { in change_hat()
1058 root = aa_get_profile_rcu(&profile->parent); in change_hat()
1059 } else if (!sibling && !PROFILE_IS_HAT(profile)) { in change_hat()
1060 root = aa_get_profile(profile); in change_hat()
1069 if (!COMPLAIN_MODE(profile)) in change_hat()
1092 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1093 if (!list_empty(&profile->base.profiles)) { in change_hat()
1103 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1111 if (count > 1 || COMPLAIN_MODE(profile)) { in change_hat()
1112 aa_audit_file(profile, &nullperms, OP_CHANGE_HAT, in change_hat()
1120 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in change_hat()
1121 build_change_hat(profile, name, sibling), in change_hat()
1122 aa_get_label(&profile->label)); in change_hat()
1154 struct aa_profile *profile; in aa_change_hat() local
1252 fn_for_each_in_ns(label, profile, in aa_change_hat()
1253 aa_audit_file(profile, &perms, OP_CHANGE_HAT, in aa_change_hat()
1262 struct aa_profile *profile, in change_profile_perms_wrapper() argument
1270 error = change_profile_perms(profile, target, stack, request, in change_profile_perms_wrapper()
1271 profile->file.start, perms); in change_profile_perms_wrapper()
1273 error = aa_audit_file(profile, perms, op, request, name, in change_profile_perms_wrapper()
1297 struct aa_profile *profile; in aa_change_profile() local
1378 error = fn_for_each_in_ns(label, profile, in aa_change_profile()
1380 profile, target, stack, in aa_change_profile()
1391 if (error && !fn_for_each_in_ns(label, profile, in aa_change_profile()
1392 COMPLAIN_MODE(profile))) in aa_change_profile()
1407 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in aa_change_profile()
1409 aa_get_label(&profile->label)); in aa_change_profile()
1449 error = fn_for_each_in_ns(label, profile, in aa_change_profile()
1450 aa_audit_file(profile, &perms, op, request, auditname, in aa_change_profile()