summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorGaosheng Cui <cuigaosheng1@huawei.com>2022-08-23 09:15:03 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-31 13:14:21 +0100
commit775a37ffa9f4681c4ad84c8634a7eec8af7098d4 (patch)
tree4e7fa6cc98f01995b1bf2dd487c27b01781bcd08 /security
parent09f30f394e832ed09859b6a80fdd20668a9104ff (diff)
downloadlinux-775a37ffa9f4681c4ad84c8634a7eec8af7098d4.tar.gz
linux-775a37ffa9f4681c4ad84c8634a7eec8af7098d4.tar.bz2
linux-775a37ffa9f4681c4ad84c8634a7eec8af7098d4.zip
apparmor: fix a memleak in multi_transaction_new()
[ Upstream commit c73275cf6834787ca090317f1d20dbfa3b7f05aa ] In multi_transaction_new(), the variable t is not freed or passed out on the failure of copy_from_user(t->data, buf, size), which could lead to a memleak. Fix this bug by adding a put_multi_transaction(t) in the error path. Fixes: 1dea3b41e84c5 ("apparmor: speed up transactional queries") Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com> Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'security')
-rw-r--r--security/apparmor/apparmorfs.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index a891705b1d57..8c7719108d7f 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -867,8 +867,10 @@ static struct multi_transaction *multi_transaction_new(struct file *file,
if (!t)
return ERR_PTR(-ENOMEM);
kref_init(&t->count);
- if (copy_from_user(t->data, buf, size))
+ if (copy_from_user(t->data, buf, size)) {
+ put_multi_transaction(t);
return ERR_PTR(-EFAULT);
+ }
return t;
}