From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF8F0C04E84 for ; Thu, 16 May 2019 02:56:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7E7320873 for ; Thu, 16 May 2019 02:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557975368; bh=TQQOh+GWzjppP/yoefvWnQUIY57aNXLvaCVcxSM4Cos=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=Z74mj5Dl3gSzi1jy20Zqdw1s51/acp1jFLBEf/tGdBz8QwRZWCVvOkDYa0GfYK/z6 PHgCPcNoKv9+8Bv1iXQnjDvSXEo997/QvIai387PSiZcJk3eUg9gzO5mX+3fk+gmJ+ +rHkiDR4DG9lpbFdzN7mHFNwsyjGk20ClghjNYLU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726188AbfEPC4H (ORCPT ); Wed, 15 May 2019 22:56:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:56234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbfEPC4H (ORCPT ); Wed, 15 May 2019 22:56:07 -0400 Received: from sol.localdomain (c-24-5-143-220.hsd1.ca.comcast.net [24.5.143.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6762520848; Thu, 16 May 2019 02:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557975366; bh=TQQOh+GWzjppP/yoefvWnQUIY57aNXLvaCVcxSM4Cos=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f8xAWetoxViGqcLLrXE1ZBoxuj5LXHi+Y3NQ0zuqiKCzm80F58a3w5bUE5CJx6LM/ Y0mtyMb19YeFXtRsO8JaRBMX63pIyDl1Lel6Lft9oy7jwqcEVmsn3Gqe5+33Bx0APv 3NOCsjwtmxfPokAtzdTUsHHw+nKK0TIV0YFF5nc8= Date: Wed, 15 May 2019 19:56:04 -0700 From: Eric Biggers To: Daniel Axtens Cc: Herbert Xu , Michael Ellerman , Nayna , leo.barbosa@canonical.com, Stephan Mueller , nayna@linux.ibm.com, omosnacek@gmail.com, leitao@debian.org, pfsmorigo@gmail.com, linux-crypto@vger.kernel.org, marcelo.cerri@canonical.com, George Wilson , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] crypto: vmx - fix copy-paste error in CTR mode Message-ID: <20190516025603.GB23200@sol.localdomain> References: <87imvkwqdh.fsf@dja-thinkpad.axtens.net> <2c8b042f-c7df-cb8b-3fcd-15d6bb274d08@linux.vnet.ibm.com> <8736mmvafj.fsf@concordia.ellerman.id.au> <20190506155315.GA661@sol.localdomain> <20190513005901.tsop4lz26vusr6o4@gondor.apana.org.au> <87pnomtwgh.fsf@concordia.ellerman.id.au> <877eat0wi0.fsf@dja-thinkpad.axtens.net> <20190515035336.y42wzhs3wzqdpwzn@gondor.apana.org.au> <874l5w1axv.fsf@dja-thinkpad.axtens.net> <871s0z171b.fsf@dja-thinkpad.axtens.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871s0z171b.fsf@dja-thinkpad.axtens.net> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, May 16, 2019 at 12:12:48PM +1000, Daniel Axtens wrote: > > I'm also seeing issues with ghash with the extended tests: > > [ 7.582926] alg: hash: p8_ghash test failed (wrong result) on test vector 0, cfg="random: use_final src_divs=[9.72%@+39832, 18.2%@+65504, 45.57%@alignmask+18, 15.6%@+65496, 6.83%@+65514, 1.2%@+25, > It seems to happen when one of the source divisions has nosimd and the > final result uses the simd finaliser, so that's interesting. > The bug is that p8_ghash uses different shash_descs for the SIMD and no-SIMD cases. So if you start out doing the hash in SIMD context but then switch to no-SIMD context or vice versa, the digest will be wrong. Note that there can be an ->export() and ->import() in between, so it's not quite as obscure a case as one might think. To fix it I think you'll need to make p8_ghash use 'struct ghash_desc_ctx' just like ghash-generic so that the two code paths can share the same shash_desc. That's similar to what the various SHA hash algorithms do. - Eric From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04B8EC04E84 for ; Thu, 16 May 2019 02:57:40 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4458020848 for ; Thu, 16 May 2019 02:57:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="f8xAWeto" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4458020848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454GLT35cKzDqZx for ; Thu, 16 May 2019 12:57:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=kernel.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=ebiggers@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="f8xAWeto"; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454GJn6zsSzDqXX for ; Thu, 16 May 2019 12:56:09 +1000 (AEST) Received: from sol.localdomain (c-24-5-143-220.hsd1.ca.comcast.net [24.5.143.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6762520848; Thu, 16 May 2019 02:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557975366; bh=TQQOh+GWzjppP/yoefvWnQUIY57aNXLvaCVcxSM4Cos=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f8xAWetoxViGqcLLrXE1ZBoxuj5LXHi+Y3NQ0zuqiKCzm80F58a3w5bUE5CJx6LM/ Y0mtyMb19YeFXtRsO8JaRBMX63pIyDl1Lel6Lft9oy7jwqcEVmsn3Gqe5+33Bx0APv 3NOCsjwtmxfPokAtzdTUsHHw+nKK0TIV0YFF5nc8= Date: Wed, 15 May 2019 19:56:04 -0700 From: Eric Biggers To: Daniel Axtens Subject: Re: [PATCH] crypto: vmx - fix copy-paste error in CTR mode Message-ID: <20190516025603.GB23200@sol.localdomain> References: <87imvkwqdh.fsf@dja-thinkpad.axtens.net> <2c8b042f-c7df-cb8b-3fcd-15d6bb274d08@linux.vnet.ibm.com> <8736mmvafj.fsf@concordia.ellerman.id.au> <20190506155315.GA661@sol.localdomain> <20190513005901.tsop4lz26vusr6o4@gondor.apana.org.au> <87pnomtwgh.fsf@concordia.ellerman.id.au> <877eat0wi0.fsf@dja-thinkpad.axtens.net> <20190515035336.y42wzhs3wzqdpwzn@gondor.apana.org.au> <874l5w1axv.fsf@dja-thinkpad.axtens.net> <871s0z171b.fsf@dja-thinkpad.axtens.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871s0z171b.fsf@dja-thinkpad.axtens.net> User-Agent: Mutt/1.11.4 (2019-03-13) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leo.barbosa@canonical.com, nayna@linux.ibm.com, Herbert Xu , Stephan Mueller , Nayna , omosnacek@gmail.com, marcelo.cerri@canonical.com, pfsmorigo@gmail.com, linux-crypto@vger.kernel.org, leitao@debian.org, George Wilson , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Thu, May 16, 2019 at 12:12:48PM +1000, Daniel Axtens wrote: > > I'm also seeing issues with ghash with the extended tests: > > [ 7.582926] alg: hash: p8_ghash test failed (wrong result) on test vector 0, cfg="random: use_final src_divs=[9.72%@+39832, 18.2%@+65504, 45.57%@alignmask+18, 15.6%@+65496, 6.83%@+65514, 1.2%@+25, > It seems to happen when one of the source divisions has nosimd and the > final result uses the simd finaliser, so that's interesting. > The bug is that p8_ghash uses different shash_descs for the SIMD and no-SIMD cases. So if you start out doing the hash in SIMD context but then switch to no-SIMD context or vice versa, the digest will be wrong. Note that there can be an ->export() and ->import() in between, so it's not quite as obscure a case as one might think. To fix it I think you'll need to make p8_ghash use 'struct ghash_desc_ctx' just like ghash-generic so that the two code paths can share the same shash_desc. That's similar to what the various SHA hash algorithms do. - Eric