Received: by 10.223.185.116 with SMTP id b49csp737855wrg; Fri, 16 Feb 2018 06:27:51 -0800 (PST) X-Google-Smtp-Source: AH8x226p81Ir9YOhiltOGqghb2j9EZnBsaO5LPLrbWWakbgiyDSDfhxxrAoB6mBueKW7n6Tsp7aY X-Received: by 2002:a17:902:47c2:: with SMTP id d2-v6mr6195613plh.222.1518791271621; Fri, 16 Feb 2018 06:27:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518791271; cv=none; d=google.com; s=arc-20160816; b=KRMsj+XmrJ+RDP6yzVRiDS8yV8RIqPnTfH4KocBbpPsWKFGaA0SuyqGFdpOyY0BrR1 PcoGdxyq9EejSj3Me4T4GgmMDHdBDE+EnIBvKSV2GFZDg+hJNbOFeJJYA749UQFgHE5q wBCe8zlhz84jpyFeuz/Y58dNw4SndtWJcoWcVzJG9qiaNsjobizQaK8stL3H+oOcGXcV +UO2juPQFqqcSpDhA4nw6oWv8xCo6LjCqQ7ogsmAxIowPm+6sFA5A6si6dYI3cYRog+H LqZqDWYKjiQMWJds582RnQWRjWYtTDaIOCOQx3ytxFgX+Ye9CNvvxYkpgConxMj1FDSf sU2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=WEsB8OlQa1QdvQp0EMowQrlj8tMIG2RA10HGgzxafc8=; b=ABBGZ/O2JcgUYUAIJM6tB7Ro49Zv+WePxT/w9HHYRA9fqA1p3ZBI7JD6UBqv9i+Wab wZ7Yoxfen5EE4YREUTf6CX/oiQHtVH2luIeYZ4YiIeqvepZv65t1Zoe8wNIh8HAJO1Lm NcKIX/bpHwfjHNC8jUy7+UYg6C5EjSzxziTNdZWHP2f2OwQ5ll8aRo9JdBjPcpG3GKNq FGnwioT3EjNUfcUJGemKJdYykPCI3jAlc0f7ZGYnBQCKKeTPJvGbhnf9jmQU5kCkPbI4 /jTJzJJgN2A7AVQwzNgx/UbgPSx17ZqAFs2HndL8xT9wrKHbYASefbyRfSdzzL6vY+O1 zbeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si1401193pgo.550.2018.02.16.06.27.36; Fri, 16 Feb 2018 06:27:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1167075AbeBOTCX (ORCPT + 99 others); Thu, 15 Feb 2018 14:02:23 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:47748 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161236AbeBOPTI (ORCPT ); Thu, 15 Feb 2018 10:19:08 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 88A251026; Thu, 15 Feb 2018 15:19:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aurelien Aptel , Steve French , Pavel Shilovsky Subject: [PATCH 3.18 13/45] CIFS: zero sensitive data when freeing Date: Thu, 15 Feb 2018 16:17:04 +0100 Message-Id: <20180215144118.632102898@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215144115.863307741@linuxfoundation.org> References: <20180215144115.863307741@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aurelien Aptel commit 97f4b7276b829a8927ac903a119bef2f963ccc58 upstream. also replaces memset()+kfree() by kzfree(). Signed-off-by: Aurelien Aptel Signed-off-by: Steve French Reviewed-by: Pavel Shilovsky Signed-off-by: Greg Kroah-Hartman --- 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 @@ -303,9 +303,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 @@ -1650,7 +1650,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; } @@ -1688,7 +1688,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); @@ -4046,7 +4046,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 @@ -99,14 +99,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); }