The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     ee008a19f1c72c37ffa54326a592035dddb66fd6
Gitweb:        
https://git.kernel.org/tip/ee008a19f1c72c37ffa54326a592035dddb66fd6
Author:        Hans de Goede <hdego...@redhat.com>
AuthorDate:    Mon, 07 Oct 2019 15:47:24 +02:00
Committer:     Ingo Molnar <mi...@kernel.org>
CommitterDate: Mon, 07 Oct 2019 16:47:35 +02:00

x86/boot: Provide memzero_explicit()

The purgatory code now uses the shared lib/crypto/sha256.c sha256
implementation. This needs memzero_explicit(), implement this.

We also have barrier_data() call after the memset, making sure
neither the compiler nor the linker optimizes out this seemingly
unused function.

Reported-by: Arvind Sankar <nived...@alum.mit.edu>
Signed-off-by: Hans de Goede <hdego...@redhat.com>
Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>
Cc: Borislav Petkov <b...@alien8.de>
Cc: H . Peter Anvin <h...@zytor.com>
Cc: Herbert Xu <herb...@gondor.apana.org.au>
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Thomas Gleixner <t...@linutronix.de>
Cc: linux-cry...@vger.kernel.org
Fixes: 906a4bb97f5d ("crypto: sha256 - Use get/put_unaligned_be32 to get input, 
memzero_explicit")
Link: https://lkml.kernel.org/r/20191007134724.4019-1-hdego...@redhat.com
[ Added comment. ]
Signed-off-by: Ingo Molnar <mi...@kernel.org>
---
 arch/x86/boot/compressed/string.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/x86/boot/compressed/string.c 
b/arch/x86/boot/compressed/string.c
index 81fc1ea..dd30e63 100644
--- a/arch/x86/boot/compressed/string.c
+++ b/arch/x86/boot/compressed/string.c
@@ -50,6 +50,16 @@ void *memset(void *s, int c, size_t n)
        return s;
 }
 
+void memzero_explicit(void *s, size_t count)
+{
+       memset(s, 0, count);
+       /*
+        * Make sure this function never gets inlined and
+        * the memset() never gets optimized away:
+        */
+       barrier_data(s);
+}
+
 void *memmove(void *dest, const void *src, size_t n)
 {
        unsigned char *d = dest;

Reply via email to