lkml.org 
[lkml]   [2022]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 300/389] apparmor: Fix memleak in aa_simple_write_to_buffer()
    Date
    From: Xiu Jianfeng <xiujianfeng@huawei.com>

    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>
    ---
    security/apparmor/apparmorfs.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- a/security/apparmor/apparmorfs.c
    +++ b/security/apparmor/apparmorfs.c
    @@ -403,7 +403,7 @@ static struct aa_loaddata *aa_simple_wri

    data->size = copy_size;
    if (copy_from_user(data->data, userbuf, copy_size)) {
    - kvfree(data);
    + aa_put_loaddata(data);
    return ERR_PTR(-EFAULT);
    }


    \
     
     \ /
      Last update: 2022-08-23 13:55    [W:4.092 / U:0.276 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site