public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] replace memset by memzero_explicit
@ 2014-11-30 17:03 Julia Lawall
  2014-11-30 17:03 ` [PATCH 1/8 v2] purgatory/sha256: " Julia Lawall
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Julia Lawall @ 2014-11-30 17:03 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kernel-janitors, linux-raid, dm-devel, linux-kernel, linux-crypto,
	sparclinux, linux-cifs, samba-technical, linuxppc-dev, linux-usb

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.  The complete semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier x;
local idexpression e;
type T,T1;
@@

{
... when any
T x[...];
... when any
    when exists
(
e = (T1)x
|
e = (T1)&x[0]
)
... when any
    when exists
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
    when != e
    when strict
}

@@
identifier i,x;
local idexpression e;
type T;
@@

{
... when any
struct i x;
... when any
    when exists
e = (T)&x
... when any
    when exists
- memset
+ memzero_explicit
  (&x,
-0,
  ...)
... when != x
    when != e
    when strict
}

// ------------------------------------------------------------------------

@@
identifier x;
type T,T1;
expression e;
@@

{
... when any
T x[...];
... when any
    when exists
    when != e = (T1)x
    when != e = (T1)&x[0]
- memset
+ memzero_explicit
  (x,
-0,
  ...)
... when != x
    when strict
}

@@
identifier i,x;
expression e;
type T;
@@

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-12-02 14:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-30 17:03 [PATCH 0/8] replace memset by memzero_explicit Julia Lawall
2014-11-30 17:03 ` [PATCH 1/8 v2] purgatory/sha256: " Julia Lawall
2014-11-30 17:03 ` [PATCH 2/8 v2] sparc64: " Julia Lawall
2014-12-02 14:58   ` Herbert Xu
2014-11-30 17:03 ` [PATCH 3/8 v2] crypto: " Julia Lawall
2014-11-30 17:03 ` [PATCH 4/8 v2] cifs: " Julia Lawall
2014-11-30 17:03 ` [PATCH 5/8 v2] dm: " Julia Lawall
2014-12-01 21:03   ` Milan Broz
2014-12-01 23:00     ` Mike Snitzer
2014-11-30 17:03 ` [PATCH 6/8 v2] crypto: " Julia Lawall
2014-12-01  0:58   ` Michael Ellerman
2014-11-30 17:03 ` [PATCH 7/8 " Julia Lawall
2014-11-30 19:57   ` Ard Biesheuvel
2014-11-30 17:03 ` [PATCH 8/8 v2] wusb: " Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox