public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] replace memset by memzero_explicit
@ 2014-11-30 16:59 Julia Lawall
  2014-11-30 16:59 ` [PATCH 1/8] purgatory/sha256: " Julia Lawall
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Julia Lawall @ 2014-11-30 16:59 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: dborkman, herbert, 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] 12+ messages in thread

end of thread, other threads:[~2014-12-03  0:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-30 16:59 [PATCH 0/8] replace memset by memzero_explicit Julia Lawall
2014-11-30 16:59 ` [PATCH 1/8] purgatory/sha256: " Julia Lawall
2014-12-01 15:20   ` David Sterba
2014-11-30 16:59 ` [PATCH 2/8] sparc64: " Julia Lawall
2014-11-30 16:59 ` [PATCH 3/8] crypto: " Julia Lawall
2014-11-30 16:59 ` [PATCH 4/8] cifs: " Julia Lawall
2014-11-30 16:59 ` [PATCH 5/8] dm: " Julia Lawall
2014-11-30 16:59 ` [PATCH 6/8] crypto: " Julia Lawall
2014-11-30 16:59 ` [PATCH 7/8] " Julia Lawall
2014-11-30 16:59 ` [PATCH 8/8] wusb: " Julia Lawall
2014-12-03  0:14   ` Greg Kroah-Hartman
2014-12-03  0:18     ` Daniel Borkmann

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