Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2321659imm; Thu, 7 Jun 2018 08:45:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJt0nY6repvoRfLhKQyv+Xf0A+QHu9xZnoDEfYs97h8A2/kMsW3mYIlJZDaYldnbQEKkN7G X-Received: by 2002:a17:902:680c:: with SMTP id h12-v6mr2619041plk.113.1528386321490; Thu, 07 Jun 2018 08:45:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528386321; cv=none; d=google.com; s=arc-20160816; b=EABfMqlvOLac03dS27TQeh3iZA8cXvofP6g+/L/1UjoYjReIV0EPDrkWD0qmbaabGI 3/JAnK7zgazdhQGNLBuTqronTdML71XmR7yDhT14y2w264a73KY4koESeiVekLhLeS0F 3JKDAJ+GN8miQpciB1lY26xrO56c9KfrnU11ygH9wsOX3qWmV8jHjaa50+X1ZZtl2m/p 0jwuQNdVi2Jn/2qhsREu6KzjmI0KVQid86yj2/9jplE3X34O+uoeu4S25Shgy+C1XxnV xF1BI0+LO7Wa5Ay7vLNOh97FGdh3H0rgKDJkto6HJzYmYMlt2SBHix3IcqrasPICV/YG E+2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=HEfvchI1yKMySSnuta1Z7LKtRPv2+PfwAGSKuLqG1WI=; b=R2p7qZyKi3WWXOHA12PsJIMOTgsdytppcLfbnSiKSvZRmvSQdL+D3mogo+5IOtOJ0X T0xIGEdU9KyTmNEbipYA++e6Tbfxee5sdn/ku7htFAhrZ5kLRPrkthmkSqbqbCb17vb7 qRcdUpTBkFfDJlQysWb2NbkHfUFub9zrqB3Aq2QH5r69hceLhnj0AZnvgO/px9xRQvpz OlRfLoihDqm8mj7UApu6nOUsuvwc/kUyhNfh4O0k4L5tEuMVHEOsGt7mpr22BN7vFvfs gOx6jRsgCOoRBgVZ362SVCwOjjXl6rYop6bnjwfjNaDcUzB3bnYpAKh3w9joqAkJmZz+ Bpog== 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 d10-v6si16558044pgu.626.2018.06.07.08.45.07; Thu, 07 Jun 2018 08:45:21 -0700 (PDT) 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 S934125AbeFGOlW (ORCPT + 99 others); Thu, 7 Jun 2018 10:41:22 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40580 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932931AbeFGOlT (ORCPT ); Thu, 7 Jun 2018 10:41:19 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbm-0005Zi-60; Thu, 07 Jun 2018 15:09:46 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb4-0002x7-FE; Thu, 07 Jun 2018 15:09:02 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Aurelien Aptel" , "Pavel Shilovsky" , "Steve French" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 171/410] CIFS: zero sensitive data when freeing In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 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: Ben Hutchings --- 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 @@ -1614,7 +1614,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; } @@ -1652,7 +1652,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); @@ -4039,7 +4039,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 * @@ -137,10 +134,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); }