Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5536929ybp; Tue, 8 Oct 2019 04:35:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvh+lFx4ZRRwSXp4Z1TxmWacxMMAo+uiH7b1GX5r1dzPveR3+K9hd4Q8kXlOjxLIfDWCLq X-Received: by 2002:a17:907:447d:: with SMTP id oo21mr6497516ejb.84.1570534530621; Tue, 08 Oct 2019 04:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570534530; cv=none; d=google.com; s=arc-20160816; b=xwMr4NKhiqOB18Jz86brbphVrb1OVqiYtDl1g2BhsqOEQBHuNYCYMFWwFEygD9ePf5 wwolMR47poFd/GGnaNUoes6Gr2EW9P6vYHs8zNUgyIRIaVieYxzx90S145JtAAJQqFeT cSgZJteBLr2goTI2p7Sm95Uphl2to71MmnXzo9VZ1KJtdRzZYi+vXSbAISPC3Df9+bBk 3El+/J1HhGvCFK94OfwoFACtBWABmBZV+5tRPX2bvOkboLI3dcowoz2bi/1fnOwWhcUi oMZpwVZY6gvgQFG55T3YYkjDbLVeR1H3rJRDszNEUIQ/K2qJnYFAk3l/FxaHxxtPjENx cXhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=uzPiaEdBd7S5Qp6HCADZuN3+lT12X95GRFWaeKyUWvk=; b=chZKnxNbVmpWx0nQOoWKEfbXsOkVYLj1BO428+gXbhVfu0vH06iyrzDR/ELEOBuKmf mc39FyDOq8InTApKKctefNvSA6BW9pHyolT+qz6wVoDCRHgIPJZFHdGu03l453DgXmvD UrSlyDxxfvOcFwZWYlASs/ffxHEv1eeA4v6aj8/j+vRm/HrQ0nxbCpgE3Q/ZhBLA5n9k BpqVHNUlkHc4RJkJ9NfmssBPnN0jGGdg6wUbKZGGYhivB4wc4J7hvxRwLTukjyMihvhN TvYvBmDDmKIS1FzTCkK9fL/g+3f0KVYaWFxFQac1HosTVp4de0Zn5u0KwOH3ZzRmMIP/ 5qMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f57si10138581edb.165.2019.10.08.04.35.05; Tue, 08 Oct 2019 04:35:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730837AbfJHLdu (ORCPT + 99 others); Tue, 8 Oct 2019 07:33:50 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:47870 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730832AbfJHLdt (ORCPT ); Tue, 8 Oct 2019 07:33:49 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iHnkA-0008Fk-Cs; Tue, 08 Oct 2019 13:33:30 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 064D91C0325; Tue, 8 Oct 2019 13:33:30 +0200 (CEST) Date: Tue, 08 Oct 2019 11:33:29 -0000 From: "tip-bot2 for Arvind Sankar" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] lib/string: Make memzero_explicit() inline instead of external Cc: Hans de Goede , Arvind Sankar , Ard Biesheuvel , Borislav Petkov , "H . Peter Anvin" , Herbert Xu , Linus Torvalds , Peter Zijlstra , Stephan Mueller , Thomas Gleixner , linux-crypto@vger.kernel.org, linux-s390@vger.kernel.org, Ingo Molnar , linux-kernel@vger.kernel.org In-Reply-To: <20191007220000.GA408752@rani.riverdale.lan> References: <20191007220000.GA408752@rani.riverdale.lan> MIME-Version: 1.0 Message-ID: <157053440989.9978.4332514722028447332.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: bec500777089b3c96c53681fc0aa6fee59711d4a Gitweb: https://git.kernel.org/tip/bec500777089b3c96c53681fc0aa6fee59711d4a Author: Arvind Sankar AuthorDate: Mon, 07 Oct 2019 18:00:02 -04:00 Committer: Ingo Molnar CommitterDate: Tue, 08 Oct 2019 13:27:05 +02:00 lib/string: Make memzero_explicit() inline instead of external With the use of the barrier implied by barrier_data(), there is no need for memzero_explicit() to be extern. Making it inline saves the overhead of a function call, and allows the code to be reused in arch/*/purgatory without having to duplicate the implementation. Tested-by: Hans de Goede Signed-off-by: Arvind Sankar Reviewed-by: Hans de Goede Cc: Ard Biesheuvel Cc: Borislav Petkov Cc: H . Peter Anvin Cc: Herbert Xu Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephan Mueller Cc: Thomas Gleixner Cc: linux-crypto@vger.kernel.org Cc: linux-s390@vger.kernel.org Fixes: 906a4bb97f5d ("crypto: sha256 - Use get/put_unaligned_be32 to get input, memzero_explicit") Link: https://lkml.kernel.org/r/20191007220000.GA408752@rani.riverdale.lan Signed-off-by: Ingo Molnar --- include/linux/string.h | 21 ++++++++++++++++++++- lib/string.c | 21 --------------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/include/linux/string.h b/include/linux/string.h index b2f9df7..b6ccdc2 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -227,7 +227,26 @@ static inline bool strstarts(const char *str, const char *prefix) } size_t memweight(const void *ptr, size_t bytes); -void memzero_explicit(void *s, size_t count); + +/** + * 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. + * + * Note: usually using memset() is just fine (!), but in cases + * where clearing out _local_ data at the end of a scope is + * necessary, memzero_explicit() should be used instead in + * order to prevent the compiler from optimising away zeroing. + * + * memzero_explicit() doesn't need an arch-specific version as + * it just invokes the one of memset() implicitly. + */ +static inline void memzero_explicit(void *s, size_t count) +{ + memset(s, 0, count); + barrier_data(s); +} /** * kbasename - return the last part of a pathname. diff --git a/lib/string.c b/lib/string.c index cd7a10c..08ec58c 100644 --- a/lib/string.c +++ b/lib/string.c @@ -748,27 +748,6 @@ 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. - * - * Note: usually using memset() is just fine (!), but in cases - * where clearing out _local_ data at the end of a scope is - * necessary, memzero_explicit() should be used instead in - * order to prevent the compiler from optimising away zeroing. - * - * 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); - barrier_data(s); -} -EXPORT_SYMBOL(memzero_explicit); - #ifndef __HAVE_ARCH_MEMSET16 /** * memset16() - Fill a memory area with a uint16_t