Skip to content

Commit

Permalink
capabilities: fix logic for effective root or real root
Browse files Browse the repository at this point in the history
Now that the logic is inverted, it is much easier to see that both real
root and effective root conditions had to be met to avoid printing the
BPRM_FCAPS record with audit syscalls.  This meant that any setuid root
applications would print a full BPRM_FCAPS record when it wasn't
necessary, cluttering the event output, since the SYSCALL and PATH
records indicated the presence of the setuid bit and effective root user
id.

Require only one of effective root or real root to avoid printing the
unnecessary record.

Ref: commit 3fc689e ("Add audit_log_bprm_fcaps/AUDIT_BPRM_FCAPS")
See: linux-audit/audit-kernel#16

Signed-off-by: Richard Guy Briggs <[email protected]>
Reviewed-by: Serge Hallyn <[email protected]>
Acked-by: James Morris <[email protected]>
Acked-by: Kees Cook <[email protected]>
Acked-by: Paul Moore <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
rgbriggs authored and James Morris committed Oct 20, 2017
1 parent c0d1ade commit 588fb2c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions security/commoncap.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ static inline bool __is_setgid(struct cred *new, const struct cred *old)
*
* We do not bother to audit if 3 things are true:
* 1) cap_effective has all caps
* 2) we are root
* 2) we became root *OR* are were already root
* 3) root is supposed to have all caps (SECURE_NOROOT)
* Since this is just a normal root execing a process.
*
Expand All @@ -783,8 +783,7 @@ static inline bool nonroot_raised_pE(struct cred *cred, kuid_t root)

if (__cap_grew(effective, ambient, cred) &&
!(__cap_full(effective, cred) &&
__is_eff(root, cred) &&
__is_real(root, cred) &&
(__is_eff(root, cred) || __is_real(root, cred)) &&
root_privileged()))
ret = true;
return ret;
Expand Down

0 comments on commit 588fb2c

Please sign in to comment.