Skip to contentSkip to conversation

lib: memzero_explicit: add comment for its usage

PATCH Applied Daniel Borkmann 2 participants 2 messages Jan 5, 2015 – Jan 8, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: memzero_explicit: add comment for its usage

Lets improve the comment to add a note on when to use memzero_explicit() for those not digging through the git logs. We don't want people to pollute places with memzero_explicit() where it's not really necessary.

Reference: https://lkml.org/lkml/2015/1/4/190

---
[ Sending to -crypto as it's most relevant here and suggested by
Herbert anyway. ]

 lib/string.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/string.c +5 -0
index 1006330..d984ec4 100644
@@ -604,6 +604,11 @@ EXPORT_SYMBOL(memset);
  * @s: Pointer to the start of the area.
  * @count: The size of the area.
  *
+ * Note: usually using memset() is just fine (!), but in cases
+ * where clearing out _local_ data at the end of a scope is
+ * necessary, memzero_explicit() should be used instead in
+ * order to prevent the compiler from optimising away zeroing.
+ *
  * memzero_explicit() doesn't need an arch-specific version as
  * it just invokes the one of memset() implicitly.
  */
Signature · 1 line
1.7.11.7
maintainer Applied
#1 lore raw
Quoted 7 lines · Daniel Borkmann

Lets improve the comment to add a note on when to use memzero_explicit() for those not digging through the git logs. We don't want people to pollute places with memzero_explicit() where it's not really necessary.

Reference: https://lkml.org/lkml/2015/1/4/190

Applied.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt