All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <Julia.Lawall@lip6.fr>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: dborkman@redhat.com, herbert@gondor.apana.org.au,
	kernel-janitors@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, Julia Lawall <julia@diku.dk>
Subject: [PATCH 6/8] crypto: replace memset by memzero_explicit
Date: Sun, 30 Nov 2014 17:59:32 +0100	[thread overview]
Message-ID: <1417366774-32412-7-git-send-email-Julia.Lawall@lip6.fr> (raw)
In-Reply-To: <1417366774-32412-1-git-send-email-Julia.Lawall@lip6.fr>

From: Julia Lawall <julia@diku.dk>

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
    when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
    when strict
}
// </smpl>

This change was suggested by Daniel Borkmann <dborkman@redhat.com>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

 arch/powerpc/crypto/sha1.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/crypto/sha1.c b/arch/powerpc/crypto/sha1.c
index 0f88c7b..d3feba5 100644
--- a/arch/powerpc/crypto/sha1.c
+++ b/arch/powerpc/crypto/sha1.c
@@ -66,7 +66,7 @@ static int sha1_update(struct shash_desc *desc, const u8 *data,
 			src = data + done;
 		} while (done + 63 < len);
 
-		memset(temp, 0, sizeof(temp));
+		memzero_explicit(temp, sizeof(temp));
 		partial = 0;
 	}
 	memcpy(sctx->buffer + partial, src, len - done);


WARNING: multiple messages have this Message-ID (diff)
From: Julia Lawall <Julia.Lawall@lip6.fr>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: dborkman@redhat.com, kernel-janitors@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, Julia Lawall <julia@diku.dk>
Subject: [PATCH 6/8] crypto: replace memset by memzero_explicit
Date: Sun, 30 Nov 2014 16:59:32 +0000	[thread overview]
Message-ID: <1417366774-32412-7-git-send-email-Julia.Lawall@lip6.fr> (raw)
In-Reply-To: <1417366774-32412-1-git-send-email-Julia.Lawall@lip6.fr>

From: Julia Lawall <julia@diku.dk>

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
    when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
    when strict
}
// </smpl>

This change was suggested by Daniel Borkmann <dborkman@redhat.com>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

 arch/powerpc/crypto/sha1.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/crypto/sha1.c b/arch/powerpc/crypto/sha1.c
index 0f88c7b..d3feba5 100644
--- a/arch/powerpc/crypto/sha1.c
+++ b/arch/powerpc/crypto/sha1.c
@@ -66,7 +66,7 @@ static int sha1_update(struct shash_desc *desc, const u8 *data,
 			src = data + done;
 		} while (done + 63 < len);
 
-		memset(temp, 0, sizeof(temp));
+		memzero_explicit(temp, sizeof(temp));
 		partial = 0;
 	}
 	memcpy(sctx->buffer + partial, src, len - done);


WARNING: multiple messages have this Message-ID (diff)
From: Julia Lawall <Julia.Lawall@lip6.fr>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: herbert@gondor.apana.org.au, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org, dborkman@redhat.com,
	Paul Mackerras <paulus@samba.org>,
	linux-crypto@vger.kernel.org, Julia Lawall <julia@diku.dk>,
	linuxppc-dev@lists.ozlabs.org,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 6/8] crypto: replace memset by memzero_explicit
Date: Sun, 30 Nov 2014 17:59:32 +0100	[thread overview]
Message-ID: <1417366774-32412-7-git-send-email-Julia.Lawall@lip6.fr> (raw)
In-Reply-To: <1417366774-32412-1-git-send-email-Julia.Lawall@lip6.fr>

From: Julia Lawall <julia@diku.dk>

Memset on a local variable may be removed when it is called just before the
variable goes out of scope.  Using memzero_explicit defeats this
optimization.  A simplified version of the semantic patch that makes this
change is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier x;
type T;
@@

{
... when any
T x[...];
... when any
    when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
    when strict
}
// </smpl>

This change was suggested by Daniel Borkmann <dborkman@redhat.com>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
Daniel Borkmann suggested that these patches could go through Herbert Xu's
cryptodev tree.

 arch/powerpc/crypto/sha1.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/crypto/sha1.c b/arch/powerpc/crypto/sha1.c
index 0f88c7b..d3feba5 100644
--- a/arch/powerpc/crypto/sha1.c
+++ b/arch/powerpc/crypto/sha1.c
@@ -66,7 +66,7 @@ static int sha1_update(struct shash_desc *desc, const u8 *data,
 			src = data + done;
 		} while (done + 63 < len);
 
-		memset(temp, 0, sizeof(temp));
+		memzero_explicit(temp, sizeof(temp));
 		partial = 0;
 	}
 	memcpy(sctx->buffer + partial, src, len - done);

  parent reply	other threads:[~2014-11-30 16:59 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-30 16:59 [PATCH 0/8] replace memset by memzero_explicit Julia Lawall
2014-11-30 16:59 ` Julia Lawall
2014-11-30 16:59 ` Julia Lawall
2014-11-30 16:59 ` Julia Lawall
2014-11-30 16:59 ` Julia Lawall
2014-11-30 16:59 ` [PATCH 1/8] purgatory/sha256: " Julia Lawall
2014-11-30 16:59   ` Julia Lawall
2014-12-01 15:20   ` David Sterba
2014-12-01 15:20     ` David Sterba
2014-11-30 16:59 ` [PATCH 2/8] sparc64: " Julia Lawall
2014-11-30 16:59   ` Julia Lawall
2014-11-30 16:59 ` [PATCH 3/8] crypto: " Julia Lawall
2014-11-30 16:59   ` Julia Lawall
     [not found] ` <1417366774-32412-1-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2014-11-30 16:59   ` [PATCH 4/8] cifs: " Julia Lawall
2014-11-30 16:59     ` Julia Lawall
2014-11-30 16:59     ` Julia Lawall
2014-11-30 16:59 ` [PATCH 5/8] dm: " Julia Lawall
2014-11-30 16:59   ` Julia Lawall
2014-11-30 16:59 ` Julia Lawall [this message]
2014-11-30 16:59   ` [PATCH 6/8] crypto: " Julia Lawall
2014-11-30 16:59   ` Julia Lawall
2014-11-30 16:59 ` [PATCH 7/8] " Julia Lawall
2014-11-30 16:59   ` Julia Lawall
2014-11-30 16:59   ` Julia Lawall
2014-11-30 16:59 ` [PATCH 8/8] wusb: " Julia Lawall
2014-11-30 16:59   ` Julia Lawall
2014-12-03  0:14   ` Greg Kroah-Hartman
2014-12-03  0:14     ` Greg Kroah-Hartman
2014-12-03  0:18     ` Daniel Borkmann
2014-12-03  0:18       ` Daniel Borkmann
2014-11-30 17:03 [PATCH 0/8] " Julia Lawall
2014-11-30 17:03 ` Julia Lawall
2014-11-30 17:03 ` Julia Lawall
2014-11-30 17:03 ` Julia Lawall
2014-11-30 17:03 ` Julia Lawall
2014-11-30 17:03 ` [PATCH 1/8 v2] purgatory/sha256: " Julia Lawall
2014-11-30 17:03   ` Julia Lawall
2014-11-30 17:03 ` [PATCH 2/8 v2] sparc64: " Julia Lawall
2014-11-30 17:03   ` Julia Lawall
2014-12-02 14:58   ` Herbert Xu
2014-12-02 14:58     ` Herbert Xu
2014-11-30 17:03 ` [PATCH 3/8 v2] crypto: " Julia Lawall
2014-11-30 17:03   ` Julia Lawall
2014-11-30 17:03 ` [PATCH 4/8 v2] cifs: " Julia Lawall
2014-11-30 17:03   ` Julia Lawall
2014-11-30 17:03 ` [PATCH 5/8 v2] dm: " Julia Lawall
2014-11-30 17:03   ` Julia Lawall
2014-12-01 21:03   ` Milan Broz
2014-12-01 21:03     ` Milan Broz
2014-12-01 23:00     ` Mike Snitzer
2014-12-01 23:00       ` Mike Snitzer
2014-11-30 17:03 ` [PATCH 6/8 v2] crypto: " Julia Lawall
2014-11-30 17:03   ` Julia Lawall
2014-11-30 17:03   ` Julia Lawall
2014-12-01  0:58   ` Michael Ellerman
2014-12-01  0:58     ` Michael Ellerman
2014-12-01  0:58     ` Michael Ellerman
2014-11-30 17:03 ` [PATCH 7/8 " Julia Lawall
2014-11-30 17:03   ` Julia Lawall
2014-11-30 17:03   ` Julia Lawall
2014-11-30 19:57   ` Ard Biesheuvel
2014-11-30 19:57     ` Ard Biesheuvel
2014-11-30 19:57     ` Ard Biesheuvel
2014-11-30 19:57     ` Ard Biesheuvel
2014-11-30 17:03 ` [PATCH 8/8 v2] wusb: " Julia Lawall
2014-11-30 17:03   ` Julia Lawall

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=1417366774-32412-7-git-send-email-Julia.Lawall@lip6.fr \
    --to=julia.lawall@lip6.fr \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.