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 <[email protected]> AuthorDate: Mon, 07 Oct 2019 15:47:24 +02:00 Committer: Ingo Molnar <[email protected]> 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 <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: H . Peter Anvin <[email protected]> Cc: Herbert Xu <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Fixes: 906a4bb97f5d ("crypto: sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit") Link: https://lkml.kernel.org/r/[email protected] [ Added comment. ] Signed-off-by: Ingo Molnar <[email protected]> --- 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;

