From patchwork Sun Jan 4 18:05:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giel van Schijndel X-Patchwork-Id: 5564291 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AEAE0BF6C3 for ; Sun, 4 Jan 2015 19:11:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DAB212017A for ; Sun, 4 Jan 2015 19:11:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13CEF20176 for ; Sun, 4 Jan 2015 19:11:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752825AbbADTK3 (ORCPT ); Sun, 4 Jan 2015 14:10:29 -0500 Received: from khitomer.mortis.eu ([185.27.175.75]:11414 "EHLO khitomer.mortis.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752749AbbADTK1 (ORCPT ); Sun, 4 Jan 2015 14:10:27 -0500 Received: from salidar.dom.custoft.eu (unknown [IPv6:2001:981:4eab:1:15b3:6ca1:85a7:c662]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Giel van Schijndel", Issuer "CAcert Class 3 Root" (verified OK)) by khitomer.mortis.eu (Postfix) with ESMTPS id 6E049C04; Sun, 4 Jan 2015 19:05:50 +0100 (CET) Received: by salidar.dom.custoft.eu (Postfix, from userid 2079) id 17E672C8111; Sun, 4 Jan 2015 19:05:50 +0100 (CET) From: Giel van Schijndel To: linux-kernel@vger.kernel.org Cc: Giel van Schijndel , Herbert Xu , "David S. Miller" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org (maintainer:X86 ARCHITECTURE...), Greg Kroah-Hartman , Steve French , Rahul Bedarkar , Thomas Pugliese , Randy Dunlap , Julia Lawall , linux-crypto@vger.kernel.org (open list:CRYPTO API), linux-usb@vger.kernel.org (open list:CERTIFIED WIRELES...), linux-cifs@vger.kernel.org (open list:COMMON INTERNET F...), samba-technical@lists.samba.org (moderated list:COMMON INTERNET F...) Subject: [PATCH] Use memzero_explicit to clear local buffers Date: Sun, 4 Jan 2015 19:05:40 +0100 Message-Id: <1420394744-20268-1-git-send-email-me@mortis.eu> X-Mailer: git-send-email 2.1.4 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When leaving a function use memzero_explicit instead of memset(0) to clear locally allocated/owned buffers. memset(0) may be optimized away. All of the affected buffers contain sensitive data, key material or derivatives of one of those two. Signed-off-by: Giel van Schijndel --- arch/x86/crypto/sha256_ssse3_glue.c | 2 +- drivers/usb/wusbcore/security.c | 2 +- fs/cifs/smbencrypt.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/crypto/sha256_ssse3_glue.c b/arch/x86/crypto/sha256_ssse3_glue.c index 8fad72f..b616e63 100644 --- a/arch/x86/crypto/sha256_ssse3_glue.c +++ b/arch/x86/crypto/sha256_ssse3_glue.c @@ -164,7 +164,7 @@ static int sha256_ssse3_final(struct shash_desc *desc, u8 *out) dst[i] = cpu_to_be32(sctx->state[i]); /* Wipe context */ - memset(sctx, 0, sizeof(*sctx)); + memzero_explicit(sctx, sizeof(*sctx)); return 0; } diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c index b66faaf..a25f4fe 100644 --- a/drivers/usb/wusbcore/security.c +++ b/drivers/usb/wusbcore/security.c @@ -521,7 +521,7 @@ error_wusbhc_set_ptk: error_hs3: error_hs2: error_hs1: - memset(hs, 0, 3*sizeof(hs[0])); + memzero_explicit(hs, 3*sizeof(hs[0])); memzero_explicit(&keydvt_out, sizeof(keydvt_out)); memzero_explicit(&keydvt_in, sizeof(keydvt_in)); memzero_explicit(&ccm_n, sizeof(ccm_n)); diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c index 6c15663..a4232ec 100644 --- a/fs/cifs/smbencrypt.c +++ b/fs/cifs/smbencrypt.c @@ -221,7 +221,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16, } rc = mdfour(p16, (unsigned char *) wpwd, len * sizeof(__le16)); - memset(wpwd, 0, 129 * sizeof(__le16)); + memzero_explicit(wpwd, sizeof(wpwd)); return rc; }