]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
cifs: fix potential memory leaks in session setup
authorPaulo Alcantara <pc@cjr.nz>
Tue, 10 Jan 2023 23:35:46 +0000 (20:35 -0300)
committerSteve French <stfrench@microsoft.com>
Wed, 11 Jan 2023 05:24:37 +0000 (23:24 -0600)
Make sure to free cifs_ses::auth_key.response before allocating it as
we might end up leaking memory in reconnect or mounting.

Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifsencrypt.c
fs/cifs/sess.c
fs/cifs/smb2pdu.c

index 5db73c0f792a5565f6fdca2c445d3d210a76a4de..cbc18b4a9cb20c28959712c1a291ee9c4e085899 100644 (file)
@@ -278,6 +278,7 @@ build_avpair_blob(struct cifs_ses *ses, const struct nls_table *nls_cp)
         * ( for NTLMSSP_AV_NB_DOMAIN_NAME followed by NTLMSSP_AV_EOL ) +
         * unicode length of a netbios domain name
         */
+       kfree_sensitive(ses->auth_key.response);
        ses->auth_key.len = size + 2 * dlen;
        ses->auth_key.response = kzalloc(ses->auth_key.len, GFP_KERNEL);
        if (!ses->auth_key.response) {
index 0b842a07e15797b73c30a43accd9185906ad145e..c47b254f0d1e276a312f0bcca25e3c1cbf09bd9c 100644 (file)
@@ -815,6 +815,7 @@ int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
                return -EINVAL;
        }
        if (tilen) {
+               kfree_sensitive(ses->auth_key.response);
                ses->auth_key.response = kmemdup(bcc_ptr + tioffset, tilen,
                                                 GFP_KERNEL);
                if (!ses->auth_key.response) {
@@ -1428,6 +1429,7 @@ sess_auth_kerberos(struct sess_data *sess_data)
                goto out_put_spnego_key;
        }
 
+       kfree_sensitive(ses->auth_key.response);
        ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len,
                                         GFP_KERNEL);
        if (!ses->auth_key.response) {
index 727f16b426be5c718a3209fbc6f22c589195e5ab..4b71f4a92f76cf42af8de2adb868b8507c576591 100644 (file)
@@ -1453,6 +1453,7 @@ SMB2_auth_kerberos(struct SMB2_sess_data *sess_data)
 
        /* keep session key if binding */
        if (!is_binding) {
+               kfree_sensitive(ses->auth_key.response);
                ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len,
                                                 GFP_KERNEL);
                if (!ses->auth_key.response) {