Skip to content

Commit 12eb87d

Browse files
committed
apparmor: update cap audit to check SECURITY_CAP_NOAUDIT
apparmor should be checking the SECURITY_CAP_NOAUDIT constant. Also in complain mode make it so apparmor can elect to log a message, informing of the check. Signed-off-by: John Johansen <[email protected]>
1 parent 31f75bf commit 12eb87d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

security/apparmor/capability.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/capability.h>
1616
#include <linux/errno.h>
1717
#include <linux/gfp.h>
18+
#include <linux/security.h>
1819

1920
#include "include/apparmor.h"
2021
#include "include/capability.h"
@@ -55,20 +56,24 @@ static void audit_cb(struct audit_buffer *ab, void *va)
5556
* audit_caps - audit a capability
5657
* @profile: profile being tested for confinement (NOT NULL)
5758
* @cap: capability tested
59+
@audit: whether an audit record should be generated
5860
* @error: error code returned by test
5961
*
6062
* Do auditing of capability and handle, audit/complain/kill modes switching
6163
* and duplicate message elimination.
6264
*
6365
* Returns: 0 or sa->error on success, error code on failure
6466
*/
65-
static int audit_caps(struct aa_profile *profile, int cap, int error)
67+
static int audit_caps(struct aa_profile *profile, int cap, int audit,
68+
int error)
6669
{
6770
struct audit_cache *ent;
6871
int type = AUDIT_APPARMOR_AUTO;
6972
DEFINE_AUDIT_DATA(sa, LSM_AUDIT_DATA_CAP, OP_CAPABLE);
7073
sa.u.cap = cap;
7174
aad(&sa)->error = error;
75+
if (audit == SECURITY_CAP_NOAUDIT)
76+
aad(&sa)->info = "optional: no audit";
7277

7378
if (likely(!error)) {
7479
/* test if auditing is being forced */
@@ -129,11 +134,10 @@ int aa_capable(struct aa_profile *profile, int cap, int audit)
129134
{
130135
int error = profile_capable(profile, cap);
131136

132-
if (!audit) {
133-
if (COMPLAIN_MODE(profile))
134-
return complain_error(error);
135-
return error;
137+
if (audit == SECURITY_CAP_NOAUDIT) {
138+
if (!COMPLAIN_MODE(profile))
139+
return error;
136140
}
137141

138-
return audit_caps(profile, cap, error);
142+
return audit_caps(profile, cap, audit, error);
139143
}

0 commit comments

Comments
 (0)