Messages in this thread Patch in this message | | | Date | Mon, 07 Oct 2019 14:49:34 -0000 | From | "tip-bot2 for Hans de Goede" <> | Subject | [tip: x86/urgent] x86/boot: Provide memzero_explicit() |
| |
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 <hdegoede@redhat.com> AuthorDate: Mon, 07 Oct 2019 15:47:24 +02:00 Committer: Ingo Molnar <mingo@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 <nivedita@alum.mit.edu> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Borislav Petkov <bp@alien8.de> Cc: H . Peter Anvin <hpa@zytor.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-crypto@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-hdegoede@redhat.com [ Added comment. ] Signed-off-by: Ingo Molnar <mingo@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;
| |