Lines Matching full:label

119  * label_compound_match - find perms for full compound label
121 * @label: label to check access permissions for
130 * For the label A//&B//&C this does the perm match for A//&B//&C
135 struct aa_label *label, bool stack, in label_compound_match() argument
144 label_for_each(i, label, tp) { in label_compound_match()
158 label_for_each_cont(i, label, tp) { in label_compound_match()
179 * label_components_match - find perms for all subcomponents of a label
181 * @label: label to check access permissions for
190 * For the label A//&B//&C this does the perm match for each of A and B and C
195 struct aa_label *label, bool stack, in label_components_match() argument
206 label_for_each(i, label, tp) { in label_components_match()
222 label_for_each_cont(i, label, tp) { in label_components_match()
244 * label_match - do a multi-component label match
246 * @label: label to match (NOT NULL)
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()
277 * @target: label to transition to (NOT NULL)
285 * currently only matches full label A//&B//&C or individual components A, B, C
386 * Returns: label or NULL if no match found
402 if (profile->label.flags & FLAG_NULL && in find_attach()
403 &profile->label == ns_unconfined(profile->ns)) in find_attach()
495 return &candidate->label; in find_attach()
507 * @name: returns: name tested to find label (NOT NULL)
509 * Returns: refcounted label, or NULL on failure (MAYBE NULL)
514 struct aa_label *label = NULL; in x_table_lookup() local
522 * index into the resultant label in x_table_lookup()
524 for (*name = profile->file.trans.table[index]; !label && *name; in x_table_lookup()
531 label = &new_profile->label; in x_table_lookup()
534 label = aa_label_parse(&profile->label, *name, GFP_KERNEL, in x_table_lookup()
536 if (IS_ERR(label)) in x_table_lookup()
537 label = NULL; in x_table_lookup()
542 return label; in x_table_lookup()
546 * x_to_label - get target label for a given xindex
553 * find label for a transition index
555 * Returns: refcounted label or NULL if not found available
603 new = aa_get_newest_label(&profile->label); in x_to_label()
644 (profile->label.flags & FLAG_IX_ON_NAME_ERROR)) { in profile_transition()
647 new = aa_get_newest_label(&profile->label); in profile_transition()
657 AA_DEBUG("unconfined attached to new label"); in profile_transition()
661 return aa_get_newest_label(&profile->label); in profile_transition()
670 if (new && new->proxy == profile->label.proxy && info) { in profile_transition()
690 new = &new_profile->label; in profile_transition()
751 (profile->label.flags & FLAG_IX_ON_NAME_ERROR)) { in profile_onexec()
780 "variables for %s label=", xname); in profile_onexec()
794 static struct aa_label *handle_onexec(struct aa_label *label, in handle_onexec() argument
804 AA_BUG(!label); in handle_onexec()
810 error = fn_for_each_in_ns(label, profile, in handle_onexec()
815 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in handle_onexec()
822 error = fn_for_each_in_ns(label, profile, 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()
838 error = fn_for_each_in_ns(label, profile, in handle_onexec()
842 "failed to build target label", -ENOMEM)); in handle_onexec()
857 struct aa_label *label, *new = NULL; in apparmor_bprm_creds_for_exec() local
874 label = aa_get_newest_label(cred_label(bprm->cred)); in apparmor_bprm_creds_for_exec()
877 * Detect no new privs being set, and store the label it in apparmor_bprm_creds_for_exec()
883 if ((bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS) && !unconfined(label) && in apparmor_bprm_creds_for_exec()
885 ctx->nnp = aa_get_label(label); in apparmor_bprm_creds_for_exec()
896 new = handle_onexec(label, ctx->onexec, ctx->token, in apparmor_bprm_creds_for_exec()
899 new = fn_label_build(label, profile, GFP_KERNEL, in apparmor_bprm_creds_for_exec()
921 !unconfined(label) && in apparmor_bprm_creds_for_exec()
934 /* TODO: test needs to be profile of label to new */ in apparmor_bprm_creds_for_exec()
943 "label=", bprm->filename); in apparmor_bprm_creds_for_exec()
950 if (label->proxy != new->proxy) { in apparmor_bprm_creds_for_exec()
954 "bits. %s label=", bprm->filename); in apparmor_bprm_creds_for_exec()
965 aa_put_label(label); in apparmor_bprm_creds_for_exec()
971 error = fn_for_each(label, profile, in apparmor_bprm_creds_for_exec()
986 * Returns: label for hat transition OR ERR_PTR. Does NOT return NULL
1022 hat ? &hat->label : NULL, GLOBAL_ROOT_UID, info, in build_change_hat()
1027 * complain mode allow by returning hat->label in build_change_hat()
1029 return &hat->label; in build_change_hat()
1034 * Returns: label for hat transition or ERR_PTR. Does not return NULL
1036 static struct aa_label *change_hat(struct aa_label *label, const char *hats[], in change_hat() argument
1046 AA_BUG(!label); in change_hat()
1050 if (PROFILE_IS_HAT(labels_profile(label))) in change_hat()
1056 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1092 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1103 label_for_each_in_ns(it, labels_ns(label), label, profile) { in change_hat()
1120 new = fn_label_build_in_ns(label, profile, GFP_KERNEL, in change_hat()
1122 aa_get_label(&profile->label)); in change_hat()
1124 info = "label build failed"; in change_hat()
1153 struct aa_label *label, *previous, *new = NULL, *target = NULL; in aa_change_hat() local
1161 label = aa_get_newest_cred_label(cred); in aa_change_hat()
1165 * Detect no new privs being set, and store the label it in aa_change_hat()
1171 if (task_no_new_privs(current) && !unconfined(label) && !ctx->nnp) in aa_change_hat()
1172 ctx->nnp = aa_get_label(label); in aa_change_hat()
1174 if (unconfined(label)) { in aa_change_hat()
1181 new = change_hat(label, hats, count, flags); in aa_change_hat()
1198 if (task_no_new_privs(current) && !unconfined(label) && in aa_change_hat()
1219 if (task_no_new_privs(current) && !unconfined(label) && in aa_change_hat()
1227 /* Return to saved label. Kill task if restore fails in aa_change_hat()
1242 aa_put_label(label); in aa_change_hat()
1252 fn_for_each_in_ns(label, profile, in aa_change_hat()
1296 struct aa_label *label, *new = NULL, *target = NULL; in aa_change_profile() local
1307 label = aa_get_current_label(); in aa_change_profile()
1310 * Detect no new privs being set, and store the label it in aa_change_profile()
1316 if (task_no_new_privs(current) && !unconfined(label) && !ctx->nnp) in aa_change_profile()
1317 ctx->nnp = aa_get_label(label); in aa_change_profile()
1320 aa_put_label(label); in aa_change_profile()
1344 target = aa_label_parse(label, fqname, GFP_KERNEL, true, false); in aa_change_profile()
1348 info = "label not found"; in aa_change_profile()
1356 !COMPLAIN_MODE(labels_profile(label))) in aa_change_profile()
1359 tprofile = aa_new_null_profile(labels_profile(label), false, in aa_change_profile()
1366 target = &tprofile->label; in aa_change_profile()
1378 error = fn_for_each_in_ns(label, profile, in aa_change_profile()
1391 if (error && !fn_for_each_in_ns(label, 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()
1414 if (task_no_new_privs(current) && !unconfined(label) && in aa_change_profile()
1426 new = aa_label_merge(label, target, GFP_KERNEL); in aa_change_profile()
1428 info = "failed to build target label"; in aa_change_profile()
1449 error = fn_for_each_in_ns(label, profile, in aa_change_profile()
1457 aa_put_label(label); in aa_change_profile()