]> git.baikalelectronics.ru Git - kernel.git/commit
apparmor: fix potential label refcnt leak in aa_change_profile
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Sun, 5 Apr 2020 05:11:55 +0000 (13:11 +0800)
committerJohn Johansen <john.johansen@canonical.com>
Thu, 21 May 2020 22:25:51 +0000 (15:25 -0700)
commit4da31d905a5a7073579d480eeeb28a25c0056c75
tree5ae21032e3f1024455625f8b3af80fbf672c858a
parent2bd9d5f7472fc34e3c9f328b67da5e3bcc23de60
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: e126d0c7c2dc ("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>
security/apparmor/domain.c