lkml.org 
[lkml]   [2018]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.15 004/202] CIFS: zero sensitive data when freeing
    Date
    4.15-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Aurelien Aptel <aaptel@suse.com>

    commit 97f4b7276b829a8927ac903a119bef2f963ccc58 upstream.

    also replaces memset()+kfree() by kzfree().

    Signed-off-by: Aurelien Aptel <aaptel@suse.com>
    Signed-off-by: Steve French <smfrench@gmail.com>
    Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    fs/cifs/cifsencrypt.c | 3 +--
    fs/cifs/connect.c | 6 +++---
    fs/cifs/misc.c | 14 ++++----------
    3 files changed, 8 insertions(+), 15 deletions(-)

    --- a/fs/cifs/cifsencrypt.c
    +++ b/fs/cifs/cifsencrypt.c
    @@ -325,9 +325,8 @@ int calc_lanman_hash(const char *passwor
    {
    int i;
    int rc;
    - char password_with_pad[CIFS_ENCPWD_SIZE];
    + char password_with_pad[CIFS_ENCPWD_SIZE] = {0};

    - memset(password_with_pad, 0, CIFS_ENCPWD_SIZE);
    if (password)
    strncpy(password_with_pad, password, CIFS_ENCPWD_SIZE);

    --- a/fs/cifs/connect.c
    +++ b/fs/cifs/connect.c
    @@ -1707,7 +1707,7 @@ cifs_parse_mount_options(const char *mou
    tmp_end++;
    if (!(tmp_end < end && tmp_end[1] == delim)) {
    /* No it is not. Set the password to NULL */
    - kfree(vol->password);
    + kzfree(vol->password);
    vol->password = NULL;
    break;
    }
    @@ -1745,7 +1745,7 @@ cifs_parse_mount_options(const char *mou
    options = end;
    }

    - kfree(vol->password);
    + kzfree(vol->password);
    /* Now build new password string */
    temp_len = strlen(value);
    vol->password = kzalloc(temp_len+1, GFP_KERNEL);
    @@ -4235,7 +4235,7 @@ cifs_construct_tcon(struct cifs_sb_info
    reset_cifs_unix_caps(0, tcon, NULL, vol_info);
    out:
    kfree(vol_info->username);
    - kfree(vol_info->password);
    + kzfree(vol_info->password);
    kfree(vol_info);

    return tcon;
    --- a/fs/cifs/misc.c
    +++ b/fs/cifs/misc.c
    @@ -98,14 +98,11 @@ sesInfoFree(struct cifs_ses *buf_to_free
    kfree(buf_to_free->serverOS);
    kfree(buf_to_free->serverDomain);
    kfree(buf_to_free->serverNOS);
    - if (buf_to_free->password) {
    - memset(buf_to_free->password, 0, strlen(buf_to_free->password));
    - kfree(buf_to_free->password);
    - }
    + kzfree(buf_to_free->password);
    kfree(buf_to_free->user_name);
    kfree(buf_to_free->domainName);
    - kfree(buf_to_free->auth_key.response);
    - kfree(buf_to_free);
    + kzfree(buf_to_free->auth_key.response);
    + kzfree(buf_to_free);
    }

    struct cifs_tcon *
    @@ -136,10 +133,7 @@ tconInfoFree(struct cifs_tcon *buf_to_fr
    }
    atomic_dec(&tconInfoAllocCount);
    kfree(buf_to_free->nativeFileSystem);
    - if (buf_to_free->password) {
    - memset(buf_to_free->password, 0, strlen(buf_to_free->password));
    - kfree(buf_to_free->password);
    - }
    + kzfree(buf_to_free->password);
    kfree(buf_to_free);
    }


    \
     
     \ /
      Last update: 2018-02-15 18:03    [W:3.312 / U:0.388 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site