summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorXiu Jianfeng <xiujianfeng@huawei.com>2022-06-14 17:00:01 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-08-25 11:15:36 +0200
commit6500eb3a48ac221051b1791818a1ac74744ef617 (patch)
tree9994baffd27c5b39ca898b18c272320500bd1f85 /security
parentf4d5c7796571624e3f380b447ada52834270a287 (diff)
downloadlinux-stable-6500eb3a48ac221051b1791818a1ac74744ef617.tar.gz
linux-stable-6500eb3a48ac221051b1791818a1ac74744ef617.tar.bz2
linux-stable-6500eb3a48ac221051b1791818a1ac74744ef617.zip
apparmor: Fix memleak in aa_simple_write_to_buffer()
commit 417ea9fe972d2654a268ad66e89c8fcae67017c3 upstream. When copy_from_user failed, the memory is freed by kvfree. however the management struct and data blob are allocated independently, so only kvfree(data) cause a memleak issue here. Use aa_put_loaddata(data) to fix this issue. Fixes: a6a52579e52b5 ("apparmor: split load data into management struct and data blob") Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'security')
-rw-r--r--security/apparmor/apparmorfs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 900c865b9e5f..8868c475205f 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -403,7 +403,7 @@ static struct aa_loaddata *aa_simple_write_to_buffer(const char __user *userbuf,
data->size = copy_size;
if (copy_from_user(data->data, userbuf, copy_size)) {
- kvfree(data);
+ aa_put_loaddata(data);
return ERR_PTR(-EFAULT);
}