Skip to content

Commit 90c436a

Browse files
committed
apparmor: pass cred through to audit info.
The cred is needed to properly audit some messages, and will be needed in the future for uid conditional mediation. So pass it through to where the apparmor_audit_data struct gets defined. Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com> Signed-off-by: John Johansen <john.johansen@canonical.com>
1 parent d20f5a1 commit 90c436a

File tree

20 files changed

+388
-211
lines changed

20 files changed

+388
-211
lines changed

security/apparmor/apparmorfs.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ static ssize_t policy_update(u32 mask, const char __user *buf, size_t size,
423423
/* high level check about policy management - fine grained in
424424
* below after unpack
425425
*/
426-
error = aa_may_manage_policy(label, ns, mask);
426+
error = aa_may_manage_policy(current_cred(), label, ns, mask);
427427
if (error)
428428
goto end_section;
429429

@@ -486,7 +486,8 @@ static ssize_t profile_remove(struct file *f, const char __user *buf,
486486
/* high level check about policy management - fine grained in
487487
* below after unpack
488488
*/
489-
error = aa_may_manage_policy(label, ns, AA_MAY_REMOVE_POLICY);
489+
error = aa_may_manage_policy(current_cred(), label, ns,
490+
AA_MAY_REMOVE_POLICY);
490491
if (error)
491492
goto out;
492493

@@ -1800,7 +1801,8 @@ static int ns_mkdir_op(struct mnt_idmap *idmap, struct inode *dir,
18001801
int error;
18011802

18021803
label = begin_current_label_crit_section();
1803-
error = aa_may_manage_policy(label, NULL, AA_MAY_LOAD_POLICY);
1804+
error = aa_may_manage_policy(current_cred(), label, NULL,
1805+
AA_MAY_LOAD_POLICY);
18041806
end_current_label_crit_section(label);
18051807
if (error)
18061808
return error;
@@ -1849,7 +1851,8 @@ static int ns_rmdir_op(struct inode *dir, struct dentry *dentry)
18491851
int error;
18501852

18511853
label = begin_current_label_crit_section();
1852-
error = aa_may_manage_policy(label, NULL, AA_MAY_LOAD_POLICY);
1854+
error = aa_may_manage_policy(current_cred(), label, NULL,
1855+
AA_MAY_LOAD_POLICY);
18531856
end_current_label_crit_section(label);
18541857
if (error)
18551858
return error;

security/apparmor/capability.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ static int profile_capable(struct aa_profile *profile, int cap,
140140

141141
/**
142142
* aa_capable - test permission to use capability
143+
* @subj_cread: cred we are testing capability against
143144
* @label: label being tested for capability (NOT NULL)
144145
* @cap: capability to be tested
145146
* @opts: CAP_OPT_NOAUDIT bit determines whether audit record is generated
@@ -148,12 +149,14 @@ static int profile_capable(struct aa_profile *profile, int cap,
148149
*
149150
* Returns: 0 on success, or else an error code.
150151
*/
151-
int aa_capable(struct aa_label *label, int cap, unsigned int opts)
152+
int aa_capable(const struct cred *subj_cred, struct aa_label *label,
153+
int cap, unsigned int opts)
152154
{
153155
struct aa_profile *profile;
154156
int error = 0;
155157
DEFINE_AUDIT_DATA(ad, LSM_AUDIT_DATA_CAP, AA_CLASS_CAP, OP_CAPABLE);
156158

159+
ad.subj_cred = subj_cred;
157160
ad.common.u.cap = cap;
158161
error = fn_for_each_confined(label, profile,
159162
profile_capable(profile, cap, opts, &ad));

0 commit comments

Comments
 (0)