Skip to content

Commit 051143e

Browse files
committed
Merge tag 'apparmor-pr-2020-05-21' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor
Pull apparmor bug fixes from John Johansen: - Fix use-after-free in aa_audit_rule_init - Fix refcnt leak in policy_update - Fix potential label refcnt leak in aa_change_profile * tag 'apparmor-pr-2020-05-21' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor: apparmor: Fix use-after-free in aa_audit_rule_init apparmor: Fix aa_label refcnt leak in policy_update apparmor: fix potential label refcnt leak in aa_change_profile
2 parents 907fa89 + c54d481 commit 051143e

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

security/apparmor/apparmorfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,14 +454,15 @@ static ssize_t policy_update(u32 mask, const char __user *buf, size_t size,
454454
*/
455455
error = aa_may_manage_policy(label, ns, mask);
456456
if (error)
457-
return error;
457+
goto end_section;
458458

459459
data = aa_simple_write_to_buffer(buf, size, size, pos);
460460
error = PTR_ERR(data);
461461
if (!IS_ERR(data)) {
462462
error = aa_replace_profiles(ns, label, mask, data);
463463
aa_put_loaddata(data);
464464
}
465+
end_section:
465466
end_current_label_crit_section(label);
466467

467468
return error;

security/apparmor/audit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ int aa_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
197197
rule->label = aa_label_parse(&root_ns->unconfined->label, rulestr,
198198
GFP_KERNEL, true, false);
199199
if (IS_ERR(rule->label)) {
200+
int err = PTR_ERR(rule->label);
200201
aa_audit_rule_free(rule);
201-
return PTR_ERR(rule->label);
202+
return err;
202203
}
203204

204205
*vrule = rule;

security/apparmor/domain.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,7 @@ int aa_change_profile(const char *fqname, int flags)
13281328
ctx->nnp = aa_get_label(label);
13291329

13301330
if (!fqname || !*fqname) {
1331+
aa_put_label(label);
13311332
AA_DEBUG("no profile name");
13321333
return -EINVAL;
13331334
}
@@ -1346,8 +1347,6 @@ int aa_change_profile(const char *fqname, int flags)
13461347
op = OP_CHANGE_PROFILE;
13471348
}
13481349

1349-
label = aa_get_current_label();
1350-
13511350
if (*fqname == '&') {
13521351
stack = true;
13531352
/* don't have label_parse() do stacking */

0 commit comments

Comments
 (0)