summaryrefslogtreecommitdiffstats
path: root/lib/string.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-24 12:33:32 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-24 12:33:32 -0700
commit14d4cc08832efb724e58944ba2ac22e2ca3143dc (patch)
treefebca1365a5306d5a44b2481ec41f13f4c2defc2 /lib/string.c
parent1c45d9a920e6ef4fce38921e4fc776c2abca3197 (diff)
parent7185ad2672a7d50bc384de0e38d90b75d99f3d82 (diff)
downloadop-kernel-dev-14d4cc08832efb724e58944ba2ac22e2ca3143dc.zip
op-kernel-dev-14d4cc08832efb724e58944ba2ac22e2ca3143dc.tar.gz
Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random
Pull /dev/random updates from Ted Ts'o: "This adds a memzero_explicit() call which is guaranteed not to be optimized away by GCC. This is important when we are wiping cryptographically sensitive material" * tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random: crypto: memzero_explicit - make sure to clear out sensitive data random: add and use memzero_explicit() for clearing data
Diffstat (limited to 'lib/string.c')
-rw-r--r--lib/string.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c
index 2fc20aa..1006330 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -598,6 +598,22 @@ void *memset(void *s, int c, size_t count)
EXPORT_SYMBOL(memset);
#endif
+/**
+ * memzero_explicit - Fill a region of memory (e.g. sensitive
+ * keying data) with 0s.
+ * @s: Pointer to the start of the area.
+ * @count: The size of the area.
+ *
+ * memzero_explicit() doesn't need an arch-specific version as
+ * it just invokes the one of memset() implicitly.
+ */
+void memzero_explicit(void *s, size_t count)
+{
+ memset(s, 0, count);
+ OPTIMIZER_HIDE_VAR(s);
+}
+EXPORT_SYMBOL(memzero_explicit);
+
#ifndef __HAVE_ARCH_MEMCPY
/**
* memcpy - Copy one area of memory to another
OpenPOWER on IntegriCloud