Received: by 10.213.65.68 with SMTP id h4csp644742imn; Fri, 6 Apr 2018 06:40:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx49xiPAGhXek9J6Uioik4JjK/hkq37WSruUQHzsVlGxM27U1bSoa8HKGcrAiI2cMEaZFHq/6 X-Received: by 2002:a17:902:7446:: with SMTP id e6-v6mr27999610plt.159.1523022058304; Fri, 06 Apr 2018 06:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523022058; cv=none; d=google.com; s=arc-20160816; b=SIUl2mGmE8kIbpeB+dJvvW+IOHPc4vDHSVbkPTJrf5xdMbYBHBq2ONjM486rMbodA6 jr3Le8L0gLcfhNO8U/mfsWxqjyCHD96YSC11nZ0SJqGfjBkNwN5DKVl/3BdcDLX79dGo gO1EdmtCq+wTkbAh4hVWRbJGLHsW+ZwDBOfRTpe3ceEbskWtOs+BHqc3Tcmwp/+rUu2P ZAGAVo74QpGmdQxJLJtmu5tt82HfoK5b3YVg4l37OXv4c9T0vd9I0KS4uMTbUNDQALUg EiFGGX56jFIPS0PzBqhGfsMBDB+1H612QlV9Gd327v2YMQSbxFsY1YgDylGhipCsQq4k 1Mow== 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=XM5SFN9RmiGHnL1o9+N176+I0FD61IDxKNZjBOxidcs=; b=rEwSQVZR1si7AvMHDkSCSDfnxDe0+o04k1CV54nhPlA3CCY8QZ8EkfWmVG1E2LDfU8 37RsxaUiZ4tszptLGY7KDXAdk0mY2nhRMXaQI3X+mtQD6X4WOtnzjAdt0M9BYh1WdCei +z1nZMcztD9jpxwCO7VLKAXIulOG9dcD3BcgPXsVjebCYkN052t+RhS0RZim1ZtLxwxe iB+sUAt950Bgwk9cagc+oGIXdaod+CoSYv/dMfz47Bwam4ekwx+hIe8pm14w3p6fheNs E0Ptik/4cjNV8l0s5nXLvdlmb3jYf+RlKsexl62uArGoJyip+gzsaMiz6x+KtT7s7r19 jY2A== 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 s85si8053300pfi.32.2018.04.06.06.40.44; Fri, 06 Apr 2018 06:40:58 -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 S932678AbeDFNjh (ORCPT + 99 others); Fri, 6 Apr 2018 09:39:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34734 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932608AbeDFNje (ORCPT ); Fri, 6 Apr 2018 09:39:34 -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 27F54D0A; Fri, 6 Apr 2018 13:39:34 +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.14 53/67] crypto: x86/cast5-avx - fix ECB encryption when long sg follows short one Date: Fri, 6 Apr 2018 15:24:23 +0200 Message-Id: <20180406084347.829092660@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084341.225558262@linuxfoundation.org> References: <20180406084341.225558262@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.14-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);