From: rgb@redhat.com (Richard Guy Briggs) To: linux-security-module@vger.kernel.org Subject: [RFC PATCH V2 4/4] capabilities: auit log other surprising conditions Date: Thu, 11 May 2017 16:42:43 -0400 [thread overview] Message-ID: <1779aa46278bf6b03052c2d4a59d68a996fd61a0.1494527628.git.rgb@redhat.com> (raw) In-Reply-To: <cover.1494527628.git.rgb@redhat.com> The existing condition tested for process effective capabilities set by file attributes but intended to ignore the change if the result was unsurprisingly an effective full set in the case root is special with a setuid root executable file and we are root. Stated again: - When you execute a setuid root application, it is no surprise and expected that it got all capabilities, so we do not want capabilities recorded. if (pESET && !(pEALL && (EROOT || RROOT) && SROOT) ) Now make sure we cover other cases: - If something prevented a setuid root app getting all capabilities and it wound up with one capability only, then it is a surprise and should be logged. When it is a setuid root file, we only want capabilities when the process does not get full capabilities.. SROOT && SETUIDROOT && !pEALL - Similarly if a non-setuid program does pick up capabilities due to file system based capabilities, then we want to know what capabilities were picked up. When it has file system based capabilities we want the capabilities. !SUID && FILECAP && pPADD - If it is a non-setuid file and it gets ambient capabilities, we want the capabilities. !SUID && pAADD Related: https://github.com/linux-audit/audit-kernel/issues/16 Signed-off-by: Richard Guy Briggs <rgb@redhat.com> --- security/commoncap.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/security/commoncap.c b/security/commoncap.c index c0adee6..6309e81 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -608,7 +608,9 @@ int cap_bprm_set_creds(struct linux_binprm *bprm) * Number 1 above might fail if you don't have a full bset, but I think * that is interesting information to audit. */ - if (pESET && !(pEALL && (EROOT || RROOT) && SROOT) ) { + if ( (pESET && !(pEALL && (EROOT || RROOT) && SROOT) ) + || (SROOT && SETUIDROOT && !pEALL) + || (!SUID && ( (has_cap && pPADD) || pAADD) )) { ret = audit_log_bprm_fcaps(bprm, new, old); if (ret < 0) return ret; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info@ http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Richard Guy Briggs <rgb@redhat.com> To: linux-security-module@vger.kernel.org, linux-audit@redhat.com Cc: Richard Guy Briggs <rgb@redhat.com>, Andy Lutomirski <luto@kernel.org>, "Serge E. Hallyn" <serge.hallyn@ubuntu.com>, Kees Cook <keescook@chromium.org>, James Morris <james.l.morris@oracle.com>, Eric Paris <eparis@redhat.com>, Paul Moore <pmoore@redhat.com>, Steve Grubb <sgrubb@redhat.com> Subject: [RFC PATCH V2 4/4] capabilities: auit log other surprising conditions Date: Thu, 11 May 2017 16:42:43 -0400 [thread overview] Message-ID: <1779aa46278bf6b03052c2d4a59d68a996fd61a0.1494527628.git.rgb@redhat.com> (raw) In-Reply-To: <cover.1494527628.git.rgb@redhat.com> In-Reply-To: <cover.1494527628.git.rgb@redhat.com> The existing condition tested for process effective capabilities set by file attributes but intended to ignore the change if the result was unsurprisingly an effective full set in the case root is special with a setuid root executable file and we are root. Stated again: - When you execute a setuid root application, it is no surprise and expected that it got all capabilities, so we do not want capabilities recorded. if (pESET && !(pEALL && (EROOT || RROOT) && SROOT) ) Now make sure we cover other cases: - If something prevented a setuid root app getting all capabilities and it wound up with one capability only, then it is a surprise and should be logged. When it is a setuid root file, we only want capabilities when the process does not get full capabilities.. SROOT && SETUIDROOT && !pEALL - Similarly if a non-setuid program does pick up capabilities due to file system based capabilities, then we want to know what capabilities were picked up. When it has file system based capabilities we want the capabilities. !SUID && FILECAP && pPADD - If it is a non-setuid file and it gets ambient capabilities, we want the capabilities. !SUID && pAADD Related: https://github.com/linux-audit/audit-kernel/issues/16 Signed-off-by: Richard Guy Briggs <rgb@redhat.com> --- security/commoncap.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/security/commoncap.c b/security/commoncap.c index c0adee6..6309e81 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -608,7 +608,9 @@ int cap_bprm_set_creds(struct linux_binprm *bprm) * Number 1 above might fail if you don't have a full bset, but I think * that is interesting information to audit. */ - if (pESET && !(pEALL && (EROOT || RROOT) && SROOT) ) { + if ( (pESET && !(pEALL && (EROOT || RROOT) && SROOT) ) + || (SROOT && SETUIDROOT && !pEALL) + || (!SUID && ( (has_cap && pPADD) || pAADD) )) { ret = audit_log_bprm_fcaps(bprm, new, old); if (ret < 0) return ret; -- 1.7.1
next prev parent reply other threads:[~2017-05-11 20:42 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-05-11 20:42 [RFC PATCH V2 0/4] capabilities: do not audit log BPRM_FCAPS on set*id Richard Guy Briggs 2017-05-11 20:42 ` Richard Guy Briggs 2017-05-11 20:42 ` [RFC PATCH V2 1/4] capabilities: use macros to make the logic easier to follow and verify Richard Guy Briggs 2017-05-11 20:42 ` Richard Guy Briggs 2017-05-12 5:35 ` Serge E. Hallyn 2017-05-12 5:35 ` Serge E. Hallyn 2017-05-12 11:37 ` Richard Guy Briggs 2017-05-12 11:37 ` Richard Guy Briggs 2017-05-12 13:50 ` Serge E. Hallyn 2017-05-12 13:50 ` Serge E. Hallyn 2017-05-11 20:42 ` [RFC PATCH V2 2/4] capabilities: invert logic for clarity Richard Guy Briggs 2017-05-11 20:42 ` Richard Guy Briggs 2017-05-11 20:42 ` [RFC PATCH V2 3/4] capabilities: fix logic for effective root or real root Richard Guy Briggs 2017-05-11 20:42 ` Richard Guy Briggs 2017-05-11 20:42 ` Richard Guy Briggs [this message] 2017-05-11 20:42 ` [RFC PATCH V2 4/4] capabilities: auit log other surprising conditions Richard Guy Briggs 2017-06-02 15:19 ` [RFC PATCH V2 0/4] capabilities: do not audit log BPRM_FCAPS on set*id Paul Moore 2017-06-02 15:19 ` Paul Moore 2017-06-02 18:03 ` Richard Guy Briggs 2017-06-02 18:03 ` Richard Guy Briggs 2017-06-02 19:30 ` Paul Moore 2017-06-02 19:30 ` Paul Moore
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1779aa46278bf6b03052c2d4a59d68a996fd61a0.1494527628.git.rgb@redhat.com \ --to=rgb@redhat.com \ --cc=linux-security-module@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.