diff options
author | Gaosheng Cui | 2022-08-23 09:15:03 +0800 |
---|---|---|
committer | Greg Kroah-Hartman | 2022-12-31 13:32:29 +0100 |
commit | 3d27a436e294ac5d7a51bd5348ca63a42a468b35 (patch) | |
tree | 51a5e06c3cb4d82b7c6d9d7f8aff04ee3c8f04a6 | |
parent | 14ed46a13aba42a6ddd85de6f6274090df3586a5 (diff) |
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>
-rw-r--r-- | security/apparmor/apparmorfs.c | 4 |
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; } |