|
29 | 29 | #include "include/policy_ns.h" |
30 | 30 |
|
31 | 31 | static const char * const CONFLICTING_ATTACH_STR = "conflicting profile attachments"; |
| 32 | +static const char * const CONFLICTING_ATTACH_STR_IX = |
| 33 | + "conflicting profile attachments - ix fallback"; |
| 34 | +static const char * const CONFLICTING_ATTACH_STR_UX = |
| 35 | + "conflicting profile attachments - ux fallback"; |
32 | 36 |
|
33 | 37 | /** |
34 | 38 | * may_change_ptraced_domain - check if can change profile on ptraced task |
@@ -577,6 +581,8 @@ static struct aa_label *x_to_label(struct aa_profile *profile, |
577 | 581 | struct aa_label *stack = NULL; |
578 | 582 | struct aa_ns *ns = profile->ns; |
579 | 583 | u32 xtype = xindex & AA_X_TYPE_MASK; |
| 584 | + /* Used for info checks during fallback handling */ |
| 585 | + const char *old_info = NULL; |
580 | 586 |
|
581 | 587 | switch (xtype) { |
582 | 588 | case AA_X_NONE: |
@@ -613,12 +619,32 @@ static struct aa_label *x_to_label(struct aa_profile *profile, |
613 | 619 | /* (p|c|n)ix - don't change profile but do |
614 | 620 | * use the newest version |
615 | 621 | */ |
616 | | - *info = "ix fallback"; |
| 622 | + if (*info == CONFLICTING_ATTACH_STR) { |
| 623 | + *info = CONFLICTING_ATTACH_STR_IX; |
| 624 | + } else { |
| 625 | + old_info = *info; |
| 626 | + *info = "ix fallback"; |
| 627 | + } |
617 | 628 | /* no profile && no error */ |
618 | 629 | new = aa_get_newest_label(&profile->label); |
619 | 630 | } else if (xindex & AA_X_UNCONFINED) { |
620 | 631 | new = aa_get_newest_label(ns_unconfined(profile->ns)); |
621 | | - *info = "ux fallback"; |
| 632 | + if (*info == CONFLICTING_ATTACH_STR) { |
| 633 | + *info = CONFLICTING_ATTACH_STR_UX; |
| 634 | + } else { |
| 635 | + old_info = *info; |
| 636 | + *info = "ux fallback"; |
| 637 | + } |
| 638 | + } |
| 639 | + /* We set old_info on the code paths above where overwriting |
| 640 | + * could have happened, so now check if info was set by |
| 641 | + * find_attach as well (i.e. whether we actually overwrote) |
| 642 | + * and warn accordingly. |
| 643 | + */ |
| 644 | + if (old_info && old_info != CONFLICTING_ATTACH_STR) { |
| 645 | + pr_warn_ratelimited( |
| 646 | + "AppArmor: find_attach (from profile %s) audit info \"%s\" dropped", |
| 647 | + profile->base.hname, old_info); |
622 | 648 | } |
623 | 649 | } |
624 | 650 |
|
@@ -706,6 +732,11 @@ static struct aa_label *profile_transition(const struct cred *subj_cred, |
706 | 732 | /* hack ix fallback - improve how this is detected */ |
707 | 733 | goto audit; |
708 | 734 | } else if (!new) { |
| 735 | + if (info) { |
| 736 | + pr_warn_ratelimited( |
| 737 | + "AppArmor: %s (from profile %s) audit info \"%s\" dropped on missing transition", |
| 738 | + __func__, profile->base.hname, info); |
| 739 | + } |
709 | 740 | info = "profile transition not found"; |
710 | 741 | /* remove MAY_EXEC to audit as failure or complaint */ |
711 | 742 | perms.allow &= ~MAY_EXEC; |
|
0 commit comments