linux/security/apparmor
Xiyu Yang c701849502 apparmor: Fix aa_label refcnt leak in policy_update
commit c6b39f0707 upstream.

policy_update() invokes begin_current_label_crit_section(), which
returns a reference of the updated aa_label object to "label" with
increased refcount.

When policy_update() returns, "label" becomes invalid, so the refcount
should be decreased to keep refcount balanced.

The reference counting issue happens in one exception handling path of
policy_update(). When aa_may_manage_policy() returns not NULL, the
refcnt increased by begin_current_label_crit_section() is not decreased,
causing a refcnt leak.

Fix this issue by jumping to "end_section" label when
aa_may_manage_policy() returns not NULL.

Fixes: 5ac8c355ae ("apparmor: allow introspecting the loaded policy pre internal transform")
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>
2020-05-27 17:37:37 +02:00
..
include apparmor: don't try to replace stale label in ptrace access check 2020-01-27 14:49:55 +01:00
.gitignore
apparmorfs.c apparmor: Fix aa_label refcnt leak in policy_update 2020-05-27 17:37:37 +02:00
audit.c apparmor: Fix use-after-free in aa_audit_rule_init 2020-05-27 17:37:37 +02:00
capability.c LSM: generalize flag passing to security_capable 2020-01-23 08:21:29 +01:00
crypto.c
domain.c apparmor: fix potential label refcnt leak in aa_change_profile 2020-05-27 17:37:37 +02:00
file.c
ipc.c LSM: generalize flag passing to security_capable 2020-01-23 08:21:29 +01:00
Kconfig
label.c apparmor: fix unsigned len comparison with less than zero 2020-01-04 19:13:08 +01:00
lib.c
lsm.c apparmor: don't try to replace stale label in ptrace access check 2020-01-27 14:49:55 +01:00
Makefile
match.c
mount.c
net.c apparmor: Fix network performance issue in aa_label_sk_perm 2020-01-27 14:49:54 +01:00
nulldfa.in
path.c
policy_ns.c
policy_unpack.c apparmor: reset pos on failure to unpack for various functions 2019-09-16 08:22:16 +02:00
policy.c apparmor: fix aa_xattrs_match() may sleep while holding a RCU lock 2020-01-09 10:19:02 +01:00
procattr.c
resource.c LSM: generalize flag passing to security_capable 2020-01-23 08:21:29 +01:00
secid.c
stacksplitdfa.in
task.c