History

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

Linus Torvalds committed 12 years ago

Commit 14d4cc02 parents 1c45d9a 7185ad210 files · +36 −19Browse files

Showing the changes to lib/string.c (1 of 10 files). Show all

Unified · Split

lib/string.c+16−0
@@ -598,6 +598,22 @@ void *memset(void *s, int c, size_t count) · 597 unmodified lines
598598 EXPORT_SYMBOL(memset);
599599 #endif
600600
601+/**
602+ * memzero_explicit - Fill a region of memory (e.g. sensitive
603+ * keying data) with 0s.
604+ * @s: Pointer to the start of the area.
605+ * @count: The size of the area.
606+ *
607+ * memzero_explicit() doesn't need an arch-specific version as
608+ * it just invokes the one of memset() implicitly.
609+ */
610+void memzero_explicit(void *s, size_t count)
611+{
612+ memset(s, 0, count);
613+ OPTIMIZER_HIDE_VAR(s);
614+}
615+EXPORT_SYMBOL(memzero_explicit);
616+
601617 #ifndef __HAVE_ARCH_MEMCPY
602618 /**
603619 * memcpy - Copy one area of memory to another