From patchwork Tue Sep 27 19:46:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 9352731 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A0FA360757 for ; Tue, 27 Sep 2016 19:46:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F81E2851D for ; Tue, 27 Sep 2016 19:46:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83A7A2880F; Tue, 27 Sep 2016 19:46:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID,T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 809F52875E for ; Tue, 27 Sep 2016 19:46:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755267AbcI0Tqx (ORCPT ); Tue, 27 Sep 2016 15:46:53 -0400 Received: from mail-qk0-f172.google.com ([209.85.220.172]:33218 "EHLO mail-qk0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753284AbcI0Tqw (ORCPT ); Tue, 27 Sep 2016 15:46:52 -0400 Received: by mail-qk0-f172.google.com with SMTP id g67so27542645qkd.0 for ; Tue, 27 Sep 2016 12:46:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=S29vtDZJqer67XjwndQ3C/UoW91DOFyGB5Ufu1rhGoE=; b=M2fFImNF5DWKrChm4BYTjP+O5yXWsg4YjzLKZQjMOUU6nbbimA0XdboMRSSvqGpNxV fpjTyGJP1+sta9MwElhDaHhW1p9TNltB7zGsroI/u7w0aMifx3Rm5XvTUrvz0paq+hq7 VLwuM2jWoyhuhBKt37wSg/Piwf430z79zinQS5uhV2YgubhHVJPN4Dbe7U5CNY5VST6X PxWvYEw3ovfkbtKfnebYkB2Qn3HSFYrJYVNQZ0KYO4EpFnxDD5lAtYdooNs56Y6+6nyW 8vkbJPmgp32QZLDVIaCZQrPp66MjhiVPPuyuRVrBkMFB80l7kRzjq5Ug+wJ0x52aJSP9 SXdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=S29vtDZJqer67XjwndQ3C/UoW91DOFyGB5Ufu1rhGoE=; b=gLVhSzp2/yO5WTKKmnIOkkqlVHqC3gW6tWRhUVqAhsJCquW9Ky5Uq0QakoJLHqfZPt cIZhGTMOGwwVKR9G0AQO1pgBPXz9NHgtFHkSHaQ1RK6J0tTsYPXTjBNfEC/DjNzxjvRY Iz2xB4LmE0O0YZk9Q33LILgx4XN7VrGktP/KLjjaOJnaimXRjKOuhEkSdTfaezWebIHf 503eopMG7B/E7xzsYee+eP4bGAicGbpFmlS6FNy9pycqpNCvdp769p4zywfCaOw687qP wOM7OSpbuGV5dVvi6mT4PFDLexeAkdfMFVWLIH1qOkZT5FKzUFZdXh8moHLnaH3j2CXd xhuA== X-Gm-Message-State: AA6/9RktVl78NgExFssvoGTj82OOwek5Qeg1jinElugV8x7NS2i0S+CFHm9RDmZs9wFM1o/6 X-Received: by 10.55.198.85 with SMTP id b82mr10372842qkj.171.1475005611073; Tue, 27 Sep 2016 12:46:51 -0700 (PDT) Received: from gallifrey (189-19-115-213.dsl.telesp.net.br. [189.19.115.213]) by smtp.gmail.com with ESMTPSA id y203sm2046722qkb.31.2016.09.27.12.46.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Sep 2016 12:46:49 -0700 (PDT) Date: Tue, 27 Sep 2016 16:46:44 -0300 From: Marcelo Cerri To: Jan Stancek Cc: Herbert Xu , rui y wang , mhcerri@linux.vnet.ibm.com, leosilva@linux.vnet.ibm.com, pfsmorigo@linux.vnet.ibm.com, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7 Message-ID: <20160927194644.GB15729@gallifrey> References: <450861381.1559123.1474673197124.JavaMail.zimbra@redhat.com> <1655600242.1561022.1474676547316.JavaMail.zimbra@redhat.com> <20160926145934.GA5520@gondor.apana.org.au> <20160926174317.GA21317@gallifrey> <20160927030826.GB8579@gondor.apana.org.au> <346154437.225735.1474966863173.JavaMail.zimbra@redhat.com> <20160927120414.GC21317@gallifrey> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160927120414.GC21317@gallifrey> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Jan, Can you check if the problem occurs with this patch? --- drivers/crypto/vmx/ghash.c | 28 +++++++++++++++++----------- drivers/crypto/vmx/vmx.c | 9 +++++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/crypto/vmx/ghash.c b/drivers/crypto/vmx/ghash.c index 6c999cb0..033aba1 100644 --- a/drivers/crypto/vmx/ghash.c +++ b/drivers/crypto/vmx/ghash.c @@ -36,6 +36,8 @@ #define GHASH_DIGEST_SIZE (16) #define GHASH_KEY_LEN (16) +#define GHASH_FALLBACK_ALG "ghash-generic" + void gcm_init_p8(u128 htable[16], const u64 Xi[2]); void gcm_gmult_p8(u64 Xi[2], const u128 htable[16]); void gcm_ghash_p8(u64 Xi[2], const u128 htable[16], @@ -53,18 +55,26 @@ struct p8_ghash_desc_ctx { struct shash_desc fallback_desc; }; +int p8_ghash_fallback_descsize(void) +{ + int descsize; + struct crypto_shash *fallback; + fallback = crypto_alloc_shash(GHASH_FALLBACK_ALG, 0, + CRYPTO_ALG_NEED_FALLBACK); + if (IS_ERR(fallback)) { + return PTR_ERR(fallback); + } + descsize = crypto_shash_descsize(fallback); + crypto_free_shash(fallback); + return descsize; +} + static int p8_ghash_init_tfm(struct crypto_tfm *tfm) { - const char *alg; + const char *alg = GHASH_FALLBACK_ALG; struct crypto_shash *fallback; - struct crypto_shash *shash_tfm = __crypto_shash_cast(tfm); struct p8_ghash_ctx *ctx = crypto_tfm_ctx(tfm); - if (!(alg = crypto_tfm_alg_name(tfm))) { - printk(KERN_ERR "Failed to get algorithm name.\n"); - return -ENOENT; - } - fallback = crypto_alloc_shash(alg, 0, CRYPTO_ALG_NEED_FALLBACK); if (IS_ERR(fallback)) { printk(KERN_ERR @@ -79,10 +89,6 @@ static int p8_ghash_init_tfm(struct crypto_tfm *tfm) crypto_shash_get_flags((struct crypto_shash *) tfm)); ctx->fallback = fallback; - - shash_tfm->descsize = sizeof(struct p8_ghash_desc_ctx) - + crypto_shash_descsize(fallback); - return 0; } diff --git a/drivers/crypto/vmx/vmx.c b/drivers/crypto/vmx/vmx.c index 31a98dc..8a51149 100644 --- a/drivers/crypto/vmx/vmx.c +++ b/drivers/crypto/vmx/vmx.c @@ -28,6 +28,8 @@ #include #include +int p8_ghash_fallback_descsize(void); + extern struct shash_alg p8_ghash_alg; extern struct crypto_alg p8_aes_alg; extern struct crypto_alg p8_aes_cbc_alg; @@ -45,6 +47,7 @@ int __init p8_init(void) { int ret = 0; struct crypto_alg **alg_it; + int ghash_descsize; for (alg_it = algs; *alg_it; alg_it++) { ret = crypto_register_alg(*alg_it); @@ -59,6 +62,12 @@ int __init p8_init(void) if (ret) return ret; + ghash_descsize = p8_ghash_fallback_descsize(); + if (ghash_descsize < 0) { + printk(KERN_ERR "Cannot get descsize for p8_ghash fallback\n"); + return ghash_descsize; + } + p8_ghash_alg.descsize += ghash_descsize; ret = crypto_register_shash(&p8_ghash_alg); if (ret) { for (alg_it = algs; *alg_it; alg_it++)