Received: by 10.213.65.68 with SMTP id h4csp656422imn; Fri, 6 Apr 2018 06:52:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx49bOU8aBtj/7CZFlcjeWOc053EBS3yv45En8h9Tzzb5kpb8bM8zhLB5hxQyv1UhNVIav6Jd X-Received: by 10.99.124.1 with SMTP id x1mr17614226pgc.318.1523022769364; Fri, 06 Apr 2018 06:52:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523022769; cv=none; d=google.com; s=arc-20160816; b=N9/E+ygWCsQC8ULgZOR4WgdNTpCFNZw7GptYzn/VeEL5DOdDP8yUKhWv+RQICF4dHK Ej3S1ZYRzxoayxF/ocXboLumHgZxp8kIIlLGS4RpTZ5SsLfy2VNWK2jTbRbNdeeHvIgE Wf7niQjIEdrUbxkVIqanMPEaeUv4QHvbT4rO7Qp0XOA+fU0l1tGuc+zRutuV+EK92QJx eFGSpG643on/Zj2DLHf1g2BS9c+YnN43crZw3B/iw75UHKQU2XwRY0LG0YTV+BS6uCV9 sH1gGpduIUPcNMGWFMYN1f2mzdOp4+AQUUH6hD9SPLS5/OKYBWMQd3KR1z78QS34rK9c x86g== 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=4LlrBzrcYfzgSs1ebwDZyJfAy0HSgfBEP+5OakO7o9s=; b=FKd4bGEiRpCX4GbtSPzD2aHYJk74HIhWxp8xLUx56iJtyuuD+29EUEZBKTXM+EIynD r4NcDtkGtxGMwkHBksZvzIpMw7Jxb9jpwg6wS2DLBH0hPSpKBcFccDpvQyBpZtEPnolx oHIS9UPFuqVP7bKC5rnPbMVPM/MvMPYzpTuSYUcgamFsFPFPHRAOsZkkR902AcMWJV5Q 65N32kZxiXaoNgwyhZ6TfhuWjU/9ZStK6yXGCY+c8eZC0Dfrbb3efKep28sBVGhKwwcP IGoJlmVE9q3gmS/jO1s27nalbWUBv+fS9lmDaX3eiQ25wRU1HylPthqb5/PjC7oFeQ82 vTyg== 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 q20-v6si11215332pls.25.2018.04.06.06.52.35; Fri, 06 Apr 2018 06:52:49 -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 S1757045AbeDFNus (ORCPT + 99 others); Fri, 6 Apr 2018 09:50:48 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37888 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932962AbeDFNor (ORCPT ); Fri, 6 Apr 2018 09:44:47 -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 06779E08; Fri, 6 Apr 2018 13:44:46 +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.16 20/31] crypto: x86/cast5-avx - fix ECB encryption when long sg follows short one Date: Fri, 6 Apr 2018 15:24:45 +0200 Message-Id: <20180406084343.765391700@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084340.999820380@linuxfoundation.org> References: <20180406084340.999820380@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.16-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);