Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp312483ybi; Wed, 29 May 2019 22:03:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9mNTYdN3qBKTN1Kz/NFTQh6MT+YP7oLvZNRl/pijVoqkg+4X8ygHnpDXIyO4lI42ugjGL X-Received: by 2002:a05:6a00:43:: with SMTP id i3mr1851277pfk.113.1559192596337; Wed, 29 May 2019 22:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559192596; cv=none; d=google.com; s=arc-20160816; b=RT0vHeh92qNAJ65a+DPXHXD5ccNBlApn22+JY2OoOzhuCaH5ggRwt/VVFJ8URc7kVg S+yc9ZfQI3M/3IGR0BUtdKWY/ppTszzZx1RaKtSKid3pz+bvB4EK6Pq0bls4o4rBmtRA joviejrdYsyqlkBXJyDytRhtBJWSxLcCLxn1FghrnBo8yPe2kmLzZYBGzixa5f0vi/1L cIPDk+4aJNNFfdMTWbKcwSwRdhElWB7Mk4nBBycsR/eSk27qqf2SWJTXs6q9zkPKZijx CHIfMXHC4t+w41BG85jSd6KTq1HkG/66zBe6Hq941z/gn87SWRd7M0qFJ4aOp42V7jQS pSYw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J8McvM6jKYux1wq0GvyK1qqJAZz/hC5Yy4kvy+WEIn8=; b=K4cIC8zpDrT0y3dZzqRjLJMg93kKXIUUBuRF8Yj0C5DJAkYzPn2Suh0HE7ZWkJM+8T mi2N1A0GNjIQDINaMOgyW0jf6ptgx17P6j6zL/7h2upjNmLboeFFjc2oIoixq185Ww05 MMn1P1MwF67j4+pe+Lj+FxiXFqFLJD2EK6JKxQNeW7o1I31iRH+upDEFmHwvCT8IyioE +gtu6bBeZGsFQ0sRvLwD5QmLVKxJCKge9KDqwqqUHySg5THe6gNK4tvW6n78ejtippxg 84CgowL16lfvYeIW2r6Yd0RV54tJwRWs5JwN+/zH4+sckBsLQlWP6eZD0uLFW94m0tq8 8R+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=va1uZtzJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 p7si2371380pfn.266.2019.05.29.22.02.59; Wed, 29 May 2019 22:03:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=va1uZtzJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727554AbfE3DJ0 (ORCPT + 99 others); Wed, 29 May 2019 23:09:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:43958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727536AbfE3DJY (ORCPT ); Wed, 29 May 2019 23:09:24 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 49B6124471; Thu, 30 May 2019 03:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559185764; bh=t6bx2D04IYoytuycVZr10En/w9fgx4z/f8hlVwcsreI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=va1uZtzJJjt9IuJT9jE41sY+AZPYSRT8YYXzNbpfshAYixb/+pWwVAt2YA+es5126 0mVUhxfwNaoO7aYAZVK7iXr4M0Lz/vY28FoGqZ7aHPAK5BwSxJxksyyOBqUztHXk+S BB+MDCVX+o1QcgX8iEdc401ibrh80zwXDyCRNTRY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Axtens , Nayna Jain , Herbert Xu Subject: [PATCH 5.1 010/405] crypto: vmx - CTR: always increment IV as quadword Date: Wed, 29 May 2019 20:00:08 -0700 Message-Id: <20190530030540.936691473@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030540.291644921@linuxfoundation.org> References: <20190530030540.291644921@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Axtens commit 009b30ac7444c17fae34c4f435ebce8e8e2b3250 upstream. The kernel self-tests picked up an issue with CTR mode: alg: skcipher: p8_aes_ctr encryption test failed (wrong result) on test vector 3, cfg="uneven misaligned splits, may sleep" Test vector 3 has an IV of FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD, so after 3 increments it should wrap around to 0. In the aesp8-ppc code from OpenSSL, there are two paths that increment IVs: the bulk (8 at a time) path, and the individual path which is used when there are fewer than 8 AES blocks to process. In the bulk path, the IV is incremented with vadduqm: "Vector Add Unsigned Quadword Modulo", which does 128-bit addition. In the individual path, however, the IV is incremented with vadduwm: "Vector Add Unsigned Word Modulo", which instead does 4 32-bit additions. Thus the IV would instead become FFFFFFFFFFFFFFFFFFFFFFFF00000000, throwing off the result. Use vadduqm. This was probably a typo originally, what with q and w being adjacent. It is a pretty narrow edge case: I am really impressed by the quality of the kernel self-tests! Fixes: 5c380d623ed3 ("crypto: vmx - Add support for VMS instructions by ASM") Cc: stable@vger.kernel.org Signed-off-by: Daniel Axtens Acked-by: Nayna Jain Tested-by: Nayna Jain Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/vmx/aesp8-ppc.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/crypto/vmx/aesp8-ppc.pl +++ b/drivers/crypto/vmx/aesp8-ppc.pl @@ -1357,7 +1357,7 @@ Loop_ctr32_enc: addi $idx,$idx,16 bdnz Loop_ctr32_enc - vadduwm $ivec,$ivec,$one + vadduqm $ivec,$ivec,$one vmr $dat,$inptail lvx $inptail,0,$inp addi $inp,$inp,16