summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaosheng Cui <cuigaosheng1@huawei.com>2022-08-23 09:15:03 +0800
committerJohn Johansen <john.johansen@canonical.com>2022-10-03 14:48:54 -0700
commitc73275cf6834787ca090317f1d20dbfa3b7f05aa (patch)
treef4f9f85efcdd62d31e8f6789da75b99b538a86e9
parent3cc40a443a04d52b0c95255dce264068b01e9bfe (diff)
downloadlinux-stable-c73275cf6834787ca090317f1d20dbfa3b7f05aa.tar.gz
linux-stable-c73275cf6834787ca090317f1d20dbfa3b7f05aa.tar.bz2
linux-stable-c73275cf6834787ca090317f1d20dbfa3b7f05aa.zip
apparmor: fix a memleak in multi_transaction_new()
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>
-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 d066ccc219e2..7160e7aa58b9 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -868,8 +868,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;
}