Skip to content

Commit 89a3561

Browse files
canonical-rlee287jrjohansen
authored andcommitted
apparmor: force audit on unconfined exec if info is set by find_attach
find_attach may set info if something unusual happens during that process (currently only used to signal conflicting attachments, but this could be expanded in the future). This is information that should be propagated to userspace via an audit message. Signed-off-by: Ryan Lee <ryan.lee@canonical.com> Signed-off-by: John Johansen <john.johansen@canonical.com>
1 parent 95ff118 commit 89a3561

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

security/apparmor/domain.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,22 @@ static struct aa_label *profile_transition(const struct cred *subj_cred,
670670
if (profile_unconfined(profile)) {
671671
new = find_attach(bprm, profile->ns,
672672
&profile->ns->base.profiles, name, &info);
673+
/* info set -> something unusual that we should report
674+
* Currently this is only conflicting attachments, but other
675+
* infos added in the future should also be logged by default
676+
* and only excluded on a case-by-case basis
677+
*/
678+
if (info) {
679+
/* Because perms is never used again after this audit
680+
* we don't need to care about clobbering it
681+
*/
682+
perms.audit |= MAY_EXEC;
683+
perms.allow |= MAY_EXEC;
684+
/* Don't cause error if auditing fails */
685+
(void) aa_audit_file(subj_cred, profile, &perms,
686+
OP_EXEC, MAY_EXEC, name, target, new, cond->uid,
687+
info, error);
688+
}
673689
if (new) {
674690
AA_DEBUG(DEBUG_DOMAIN, "unconfined attached to new label");
675691
return new;

0 commit comments

Comments
 (0)