|
15 | 15 | #include <linux/capability.h> |
16 | 16 | #include <linux/errno.h> |
17 | 17 | #include <linux/gfp.h> |
| 18 | +#include <linux/security.h> |
18 | 19 |
|
19 | 20 | #include "include/apparmor.h" |
20 | 21 | #include "include/capability.h" |
@@ -55,20 +56,24 @@ static void audit_cb(struct audit_buffer *ab, void *va) |
55 | 56 | * audit_caps - audit a capability |
56 | 57 | * @profile: profile being tested for confinement (NOT NULL) |
57 | 58 | * @cap: capability tested |
| 59 | + @audit: whether an audit record should be generated |
58 | 60 | * @error: error code returned by test |
59 | 61 | * |
60 | 62 | * Do auditing of capability and handle, audit/complain/kill modes switching |
61 | 63 | * and duplicate message elimination. |
62 | 64 | * |
63 | 65 | * Returns: 0 or sa->error on success, error code on failure |
64 | 66 | */ |
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) |
66 | 69 | { |
67 | 70 | struct audit_cache *ent; |
68 | 71 | int type = AUDIT_APPARMOR_AUTO; |
69 | 72 | DEFINE_AUDIT_DATA(sa, LSM_AUDIT_DATA_CAP, OP_CAPABLE); |
70 | 73 | sa.u.cap = cap; |
71 | 74 | aad(&sa)->error = error; |
| 75 | + if (audit == SECURITY_CAP_NOAUDIT) |
| 76 | + aad(&sa)->info = "optional: no audit"; |
72 | 77 |
|
73 | 78 | if (likely(!error)) { |
74 | 79 | /* test if auditing is being forced */ |
@@ -129,11 +134,10 @@ int aa_capable(struct aa_profile *profile, int cap, int audit) |
129 | 134 | { |
130 | 135 | int error = profile_capable(profile, cap); |
131 | 136 |
|
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; |
136 | 140 | } |
137 | 141 |
|
138 | | - return audit_caps(profile, cap, error); |
| 142 | + return audit_caps(profile, cap, audit, error); |
139 | 143 | } |
0 commit comments