Skip to content

Commit a0b845f

Browse files
sherllyjrjohansen
authored andcommitted
apparmor: fix potential label refcnt leak in aa_change_profile
aa_change_profile() invokes aa_get_current_label(), which returns a reference of the current task's label. According to the comment of aa_get_current_label(), the returned reference must be put with aa_put_label(). However, when the original object pointed by "label" becomes unreachable because aa_change_profile() returns or a new object is assigned to "label", reference count increased by aa_get_current_label() is not decreased, causing a refcnt leak. Fix this by calling aa_put_label() before aa_change_profile() return and dropping unnecessary aa_get_current_label(). Fixes: 9fcf78c ("apparmor: update domain transitions that are subsets of confinement at nnp") Signed-off-by: Xiyu Yang <[email protected]> Signed-off-by: Xin Tan <[email protected]> Signed-off-by: John Johansen <[email protected]>
1 parent b85051e commit a0b845f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

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)