linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] memset() in crypto code
@ 2021-11-16 11:20 Sandy Harris
  2021-11-16 13:02 ` Christophe Leroy
  2021-11-16 14:41 ` Ard Biesheuvel
  0 siblings, 2 replies; 4+ messages in thread
From: Sandy Harris @ 2021-11-16 11:20 UTC (permalink / raw)
  To: LKML, Linux Crypto Mailing List, Greg Kroah-Hartman, Herbert Xu,
	David S. Miller

Fairly often we want to clear some memory in crypto code; it holds
things we are done using and do not want to leave lying around where
an enemy might discover them. Typical examples are crypto keys or
random numbers we have generated and used for output.

The obvious way to do this is with memset(address,0,bytes) but there
is a problem with that; because we are done using that memory, the
compiler may optimise away the "useless" memset() call. Using
memzero_explicit(address,bytes) instead solves the problem; that
function is designed to resist the optimisation.

There are well over 100 memset() calls in .c files in the crypto and
security directories. I looked at them all and found about a dozen in
eight files that I thought should be changed to memzero_explicit().
Here they are as patches 1 to 8 in this series.

I did read some code & think moderately carefully, but I do not know
the code deeply & it is possible I have made some errors. I think
false positives (making unnecessary changes) are more likely than
false negatives (not catching necessary changes).

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

end of thread, other threads:[~2021-11-17  2:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 11:20 [PATCH 0/8] memset() in crypto code Sandy Harris
2021-11-16 13:02 ` Christophe Leroy
2021-11-17  2:36   ` Sandy Harris
2021-11-16 14:41 ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).