aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiyu Yang <xiyuyang19@fudan.edu.cn>2020-04-05 13:11:55 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-05-27 17:37:37 +0200
commitdd73adb161fec02d9303ce98e0e5bf844c5d791e (patch)
tree87883c07b04ff565b1756ee50aa470f1cfe09c75
parentf1738ae012a106c6c8fa7d33ed47fb478d9d3c75 (diff)
downloadlinux-yocto-dd73adb161fec02d9303ce98e0e5bf844c5d791e.tar.gz
linux-yocto-dd73adb161fec02d9303ce98e0e5bf844c5d791e.tar.bz2
linux-yocto-dd73adb161fec02d9303ce98e0e5bf844c5d791e.zip
apparmor: fix potential label refcnt leak in aa_change_profile
commit a0b845ffa0d91855532b50fc040aeb2d8338dca4 upstream. 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: 9fcf78cca198 ("apparmor: update domain transitions that are subsets of confinement at nnp") Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com> Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--security/apparmor/domain.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
index bdf9e4cefe25..b9d5b3459705 100644
--- a/security/apparmor/domain.c
+++ b/security/apparmor/domain.c
@@ -1338,6 +1338,7 @@ int aa_change_profile(const char *fqname, int flags)
ctx->nnp = aa_get_label(label);
if (!fqname || !*fqname) {
+ aa_put_label(label);
AA_DEBUG("no profile name");
return -EINVAL;
}
@@ -1356,8 +1357,6 @@ int aa_change_profile(const char *fqname, int flags)
op = OP_CHANGE_PROFILE;
}
- label = aa_get_current_label();
-
if (*fqname == '&') {
stack = true;
/* don't have label_parse() do stacking */