Received: by 10.213.65.68 with SMTP id h4csp706193imn; Fri, 6 Apr 2018 07:35:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+JwgQK8PUY7j/X2ZesuMR7QUygg22jW15FY4KPZqw8Q7HR/+gO6PR0DAUrd17aX8eCxsZA X-Received: by 10.98.190.19 with SMTP id l19mr7744850pff.239.1523025318433; Fri, 06 Apr 2018 07:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523025318; cv=none; d=google.com; s=arc-20160816; b=L2tx6VPBddI009lZWU4oYrp4kicVkYFwB6DlPttjKfuPClz9HHCZThfQYDPQIElFvU czciUEyltlvwFxAE/b//ND+q8E67AXNl+YX5oianHTB/Wcab8XHVBe9/STE1NikpFO0G N/7Ff/Ln8UoADOWHhZMu18ZgFoSEzC16p+kkAjnzlCiRNa1iGSIfZZoGQ+nyZ0pXkHwY R8KGRX56Iaoj//NL4Z6DCinvfYgMJhAVWMPDsdd8BmKQqg/YDpWMfOHAmQnHJZj3luHT dYKGEYVhyiOMUcJTfGprSpb8VpZMhNhx103JwmEUAN9lm4qJdLTBLnWyVwUX1Ev6bIfO aYZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=kLJx2r0RFLG30UOJSAslwDWiYXBaa8alo/o5e5tsgXo=; b=RScbQE6Qng6mzbGNvh7fYVaWgT/SFK0ZC9EUgxtZfZVvz4NXjVB29JMJe+9Ft3YGsL NLGweuxFIdl3tGgeG8RTL9P7iJXHJ7j86KVIydjBCoCLQp0qjLBEo9YwRFNEgRGmjRUe tRlj0G3UxHRttUJehbEqeUz7IeolPu1Bk7VTjNyY7nkHqoeFtGnvgvMnmwIbW4SMoh48 Qzy590RGVqe/58b1bNZtbCjGcdAGLdCTnXxhj2VxcNrcXyxcsvGazYj4DgQ35WwuhgeK kzNk1D6vQLfeY+nu+7Hs8CVC5pwfT1qTUQM5fgP14DZ53abbKR0kkfOa3NsoLfUnOR0u 0F9Q== ARC-Authentication-Results: i=1; mx.google.com; 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 d5si7294415pgc.236.2018.04.06.07.35.04; Fri, 06 Apr 2018 07:35:18 -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; 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 S1752907AbeDFOeA (ORCPT + 99 others); Fri, 6 Apr 2018 10:34:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59082 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756154AbeDFNgG (ORCPT ); Fri, 6 Apr 2018 09:36:06 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DE8B2DCD; Fri, 6 Apr 2018 13:36:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Herbert Xu Subject: [PATCH 4.9 084/102] crypto: x86/cast5-avx - fix ECB encryption when long sg follows short one Date: Fri, 6 Apr 2018 15:24:05 +0200 Message-Id: <20180406084343.265931664@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit 8f461b1e02ed546fbd0f11611138da67fd85a30f upstream. With ecb-cast5-avx, if a 128+ byte scatterlist element followed a shorter one, then the algorithm accidentally encrypted/decrypted only 8 bytes instead of the expected 128 bytes. Fix it by setting the encryption/decryption 'fn' correctly. Fixes: c12ab20b162c ("crypto: cast5/avx - avoid using temporary stack buffers") Cc: # v3.8+ Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- arch/x86/crypto/cast5_avx_glue.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/arch/x86/crypto/cast5_avx_glue.c +++ b/arch/x86/crypto/cast5_avx_glue.c @@ -66,8 +66,6 @@ static int ecb_crypt(struct blkcipher_de void (*fn)(struct cast5_ctx *ctx, u8 *dst, const u8 *src); int err; - fn = (enc) ? cast5_ecb_enc_16way : cast5_ecb_dec_16way; - err = blkcipher_walk_virt(desc, walk); desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; @@ -79,6 +77,7 @@ static int ecb_crypt(struct blkcipher_de /* Process multi-block batch */ if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) { + fn = (enc) ? cast5_ecb_enc_16way : cast5_ecb_dec_16way; do { fn(ctx, wdst, wsrc);