Lines Matching full:label
117 * label_compound_match - find perms for full compound label
119 * @label: label to check access permissions for
128 * For the label A//&B//&C this does the perm match for A//&B//&C
133 struct aa_label *label, bool stack, in label_compound_match() argument
142 label_for_each(i, label, tp) { in label_compound_match()
156 label_for_each_cont(i, label, tp) { in label_compound_match()
177 * label_components_match - find perms for all subcomponents of a label
179 * @label: label to check access permissions for
188 * For the label A//&B//&C this does the perm match for each of A and B and C
193 struct aa_label *label, bool stack, in label_components_match() argument
204 label_for_each(i, label, tp) { in label_components_match()
220 label_for_each_cont(i, label, tp) { in label_components_match()
242 * label_match - do a multi-component label match
244 * @label: label to match (NOT NULL)
253 static int label_match(struct aa_profile *profile, struct aa_label *label, in label_match() argument
260 error = label_compound_match(profile, label, stack, state, subns, in label_match()
266 return label_components_match(profile, label, stack, state, subns, in label_match()
275 * @target: label to transition to (NOT NULL)
283 * currently only matches full label A//&B//&C or individual components A, B, C
384 * Returns: label or NULL if no match found
400 if (profile->label.flags & FLAG_NULL && in find_attach()
401 &profile->label == ns_unconfined(profile->ns)) in find_attach()
493 return &candidate->label; in find_attach()
505 * @name: returns: name tested to find label (NOT NULL)
507 * Returns: refcounted label, or NULL on failure (MAYBE NULL)
512 struct aa_label *label = NULL; in x_table_lookup() local
520 * index into the resultant label in x_table_lookup()
522 for (*name = profile->file.trans.table[index]; !label && *name; in x_table_lookup()
529 label = &new_profile->label; in x_table_lookup()
532 label = aa_label_parse(&profile->label, *name, GFP_KERNEL, in x_table_lookup()
534 if (IS_ERR(label)) in x_table_lookup()
535 label = NULL; in x_table_lookup()
540 return label; in x_table_lookup()
544 * x_to_label - get target label for a given xindex
551 * find label for a transition index
553 * Returns: refcounted label or NULL if not found available
601 new = aa_get_newest_label(&profile->label); in x_to_label()
642 (profile->label.flags & FLAG_IX_ON_NAME_ERROR)) { in profile_transition()
645 new = aa_get_newest_label(&profile->label); in profile_transition()
655 AA_DEBUG("unconfined attached to new label"); in profile_transition()
659 return aa_get_newest_label(&profile->label); in profile_transition()
668 if (new && new->proxy == profile->label.proxy && info) { in profile_transition()
688 new = &new_profile->label; in profile_transition()
749 (profile->label.flags & FLAG_IX_ON_NAME_ERROR)) { in profile_onexec()
778 "variables for %s label=", xname); in profile_onexec()
792 static struct aa_label *handle_onexec(struct aa_label *label, in handle_onexec() argument
802 AA_BUG(!label); in handle_onexec()
808 error = fn_for_each_in_ns(label, profile, in handle_onexec()
813 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in handle_onexec()
820 error = fn_for_each_in_ns(label, profile, in handle_onexec()
825 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in handle_onexec()
826 aa_label_merge(&profile->label, onexec, in handle_onexec()
836 error = fn_for_each_in_ns(label, profile, in handle_onexec()
840 "failed to build target label", -ENOMEM)); in handle_onexec()
855 struct aa_label *label, *new = NULL; in apparmor_bprm_creds_for_exec() local
870 label = aa_get_newest_label(cred_label(bprm->cred)); in apparmor_bprm_creds_for_exec()
873 * Detect no new privs being set, and store the label it in apparmor_bprm_creds_for_exec()
879 if ((bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS) && !unconfined(label) && in apparmor_bprm_creds_for_exec()
881 ctx->nnp = aa_get_label(label); in apparmor_bprm_creds_for_exec()
892 new = handle_onexec(label, ctx->onexec, ctx->token, in apparmor_bprm_creds_for_exec()
895 new = fn_label_build(label, profile, GFP_KERNEL, in apparmor_bprm_creds_for_exec()
917 !unconfined(label) && in apparmor_bprm_creds_for_exec()
930 /* TODO: test needs to be profile of label to new */ in apparmor_bprm_creds_for_exec()
939 "label=", bprm->filename); in apparmor_bprm_creds_for_exec()
946 if (label->proxy != new->proxy) { in apparmor_bprm_creds_for_exec()
950 "bits. %s label=", bprm->filename); in apparmor_bprm_creds_for_exec()
961 aa_put_label(label); in apparmor_bprm_creds_for_exec()
967 error = fn_for_each(label, profile, in apparmor_bprm_creds_for_exec()
983 * Returns: label for hat transition OR ERR_PTR. Does NOT return NULL
1019 hat ? &hat->label : NULL, GLOBAL_ROOT_UID, info, in build_change_hat()
1024 * complain mode allow by returning hat->label in build_change_hat()
1026 return &hat->label; in build_change_hat()
1031 * Returns: label for hat transition or ERR_PTR. Does not return NULL
1033 static struct aa_label *change_hat(struct aa_label *label, const char *hats[], in change_hat() argument
1043 AA_BUG(!label); in change_hat()
1047 if (PROFILE_IS_HAT(labels_profile(label))) in change_hat()
1053 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1089 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1100 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1117 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in change_hat()
1119 aa_get_label(&profile->label)); in change_hat()
1121 info = "label build failed"; in change_hat()
1150 struct aa_label *label, *previous, *new = NULL, *target = NULL; in aa_change_hat() local
1158 label = aa_get_newest_cred_label(cred); in aa_change_hat()
1162 * Detect no new privs being set, and store the label it in aa_change_hat()
1168 if (task_no_new_privs(current) && !unconfined(label) && !ctx->nnp) in aa_change_hat()
1169 ctx->nnp = aa_get_label(label); in aa_change_hat()
1171 if (unconfined(label)) { in aa_change_hat()
1178 new = change_hat(label, hats, count, flags); in aa_change_hat()
1195 if (task_no_new_privs(current) && !unconfined(label) && in aa_change_hat()
1216 if (task_no_new_privs(current) && !unconfined(label) && in aa_change_hat()
1224 /* Return to saved label. Kill task if restore fails in aa_change_hat()
1239 aa_put_label(label); in aa_change_hat()
1249 fn_for_each_in_ns(label, profile, in aa_change_hat()
1293 struct aa_label *label, *new = NULL, *target = NULL; in aa_change_profile() local
1304 label = aa_get_current_label(); in aa_change_profile()
1307 * Detect no new privs being set, and store the label it in aa_change_profile()
1313 if (task_no_new_privs(current) && !unconfined(label) && !ctx->nnp) in aa_change_profile()
1314 ctx->nnp = aa_get_label(label); in aa_change_profile()
1317 aa_put_label(label); in aa_change_profile()
1341 target = aa_label_parse(label, fqname, GFP_KERNEL, true, false); in aa_change_profile()
1345 info = "label not found"; in aa_change_profile()
1353 !COMPLAIN_MODE(labels_profile(label))) in aa_change_profile()
1356 tprofile = aa_new_null_profile(labels_profile(label), false, in aa_change_profile()
1363 target = &tprofile->label; in aa_change_profile()
1375 error = fn_for_each_in_ns(label, profile, in aa_change_profile()
1388 if (error && !fn_for_each_in_ns(label, profile, in aa_change_profile()
1404 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in aa_change_profile()
1406 aa_get_label(&profile->label)); in aa_change_profile()
1411 if (task_no_new_privs(current) && !unconfined(label) && in aa_change_profile()
1423 new = aa_label_merge(label, target, GFP_KERNEL); in aa_change_profile()
1425 info = "failed to build target label"; in aa_change_profile()
1446 error = fn_for_each_in_ns(label, profile, in aa_change_profile()
1454 aa_put_label(label); in aa_change_profile()