From: Giel van Schijndel <me@mortis.eu>
To: linux-kernel@vger.kernel.org
Cc: Giel van Schijndel <me@mortis.eu>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org (maintainer:X86 ARCHITECTURE...),
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Steve French <sfrench@samba.org>,
Rahul Bedarkar <rahulbedarkar89@gmail.com>,
Thomas Pugliese <thomas.pugliese@gmail.com>,
Randy Dunlap <rdunlap@infradead.org>,
Julia Lawall <Julia.Lawall@lip6.fr>,
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 [thread overview]
Message-ID: <1420394744-20268-1-git-send-email-me@mortis.eu> (raw)
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.
---
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;
}
--
2.1.4
next reply other threads:[~2015-01-04 19:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-04 18:05 Giel van Schijndel [this message]
2015-01-04 21:35 ` Herbert Xu
2015-01-04 22:49 ` Giel van Schijndel
2015-01-04 23:36 ` Herbert Xu
2015-01-06 19:42 ` Giel van Schijndel
2015-01-06 20:54 ` Herbert Xu
2015-01-04 23:05 ` Giel van Schijndel
2015-01-06 21:37 ` [PATCH RESEND] cifs: use memzero_explicit to clear stack buffer Giel van Schijndel
2015-01-06 22:59 ` Herbert Xu
2015-01-13 0:12 ` Steve French
2015-01-09 18:53 ` Steve French
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420394744-20268-1-git-send-email-me@mortis.eu \
--to=me@mortis.eu \
--cc=Julia.Lawall@lip6.fr \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rahulbedarkar89@gmail.com \
--cc=rdunlap@infradead.org \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=tglx@linutronix.de \
--cc=thomas.pugliese@gmail.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®