All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5/8] Replace memset() with memzero_explicit()
@ 2021-11-16 11:34 Sandy Harris
  0 siblings, 0 replies; only message in thread
From: Sandy Harris @ 2021-11-16 11:34 UTC (permalink / raw)
  To: LKML, Linux Crypto Mailing List, David S. Miller, Herbert Xu,
	Greg Kroah-Hartman

Replace memset(address,0,bytes) which may be optimised
away with memzero_explicit(address,bytes) which resists
such optimisation

---
 crypto/shash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/crypto/shash.c b/crypto/shash.c
index 0a0a50cb694f..f07d06f5da71 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -112,7 +112,7 @@ static int shash_update_unaligned(struct
shash_desc *desc, const u8 *data,

     memcpy(buf, data, unaligned_len);
     err = shash->update(desc, buf, unaligned_len);
-    memset(buf, 0, unaligned_len);
+    memzero_explicit(buf, unaligned_len);

     return err ?:
            shash->update(desc, data + unaligned_len, len - unaligned_len);
@@ -156,7 +156,7 @@ static int shash_final_unaligned(struct shash_desc
*desc, u8 *out)
     memcpy(out, buf, ds);

 out:
-    memset(buf, 0, ds);
+    memzero_explicit(buf, ds);
     return err;
 }

-- 
2.25.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-16 11:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 11:34 [PATCH 5/8] Replace memset() with memzero_explicit() Sandy Harris

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.