Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2664873pxa; Mon, 17 Aug 2020 15:58:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNGeN1pb18dG+lwQaTEltv6R2GQIzYadOB7CQZ7xZZStjBAUpFiNwyFJ8zODa/6JQWY0f6 X-Received: by 2002:a17:906:1a0f:: with SMTP id i15mr18410580ejf.293.1597705101588; Mon, 17 Aug 2020 15:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597705101; cv=none; d=google.com; s=arc-20160816; b=lITOSbwNWc+hy81LTIGjrvarsyinbpC+8MrDk/1lK0GJZBh53oT3x2MFTLqxcgG49q /Ftwxhsv5e+7OqjvSOnObS/n8Q6s+fo6/8HXcE6h0GCoGHRuptDQmenj1iqxjM0MHHJw Pa+o+J3Bl7eElsntj4dEyUJpHswF9pqBEYwuIcmEFlz5hM9aipQ78+4R2QlJA43orys0 COqj0FRZxPRPTgN/sjPwXziVWpVYngmcvnZKu4IWF7peMBNiPBY6hj2GKu/qPrGkR3ws I2t6D2/D06fIWHctje7CoxESUXTcgb+DB4ZPWCp6r7UgFVxhy8I52WQX3U7HINNC8Hrl RYxg== 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=wmCQoAYqO5F0zTUzmk0/9K6Q1nI/EOmIcNRittDq4EI=; b=yzmXXcRdK1ORPZLMEg4c52g5X+zGWHitdOfKZgDwfSMNpEI3SN/tqKtODDGpYpiUs7 Kvrr6PhcheeUQ8NUce6TkHLg1MPbrBdNBJ62bVnglH6lPbJ9G6zGOKxQ5ZJpRwKVtHbw w70pm8jUaoiSov93TLSw/NlHpiy0WeZJmUTLjH8sDJExuG2K7y7FGGZgMDbOupLa5K+S pku6mzou8jAAbrY4SVPBtFS/ct3axX6TBNfO7N5H8esmDoCbPoY3bDsZpQkViX/NIDFz Qy2zdWvaluS2+si+eKYNLGabjPdVzPHZd+C/CC07pf6DifvFzG81ygM8eFvUuRCQFIPi zPAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=spGct+M8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si12043159ejb.57.2020.08.17.15.57.58; Mon, 17 Aug 2020 15:58:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=spGct+M8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732815AbgHQTuQ (ORCPT + 99 others); Mon, 17 Aug 2020 15:50:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:41072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729226AbgHQPTb (ORCPT ); Mon, 17 Aug 2020 11:19:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 EAEC52065C; Mon, 17 Aug 2020 15:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597677570; bh=D/f7KeSvbnpfeuO5AHy05pktd39Vhn5bLwVvks2iLkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spGct+M8OvJHW+fuZv4E6j2URYxIR7WgP9enh9jh4ng9WoPmr1sanbwgC67wie4cx uwVk173+6T5USZ+c6Kcbgnv4PisBR18KdAom8JgQ3yGxOBJEsHP3GaXUXZaF5uocJK tgl9aSv6Sw2BNW88EzU0NmVebJDI0FRm8tadj5VE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Cabiddu , Herbert Xu , Sasha Levin Subject: [PATCH 5.8 030/464] crypto: qat - allow xts requests not multiple of block Date: Mon, 17 Aug 2020 17:09:43 +0200 Message-Id: <20200817143835.200745355@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@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: Giovanni Cabiddu [ Upstream commit 528f776df67c440361b2847b4da400d8754bf030 ] Allow AES-XTS requests that are not multiple of the block size. If a request is smaller than the block size, return -EINVAL. This fixes the following issue reported by the crypto testmgr self-test: alg: skcipher: qat_aes_xts encryption failed on test vector "random: len=116 klen=64"; expected_error=0, actual_error=-22, cfg="random: inplace may_sleep use_finup src_divs=[45.85%@+4077, 54.15%@alignmask+18]" Fixes: 96ee111a659e ("crypto: qat - return error for block...") Signed-off-by: Giovanni Cabiddu Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/qat/qat_common/qat_algs.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c index e14d3dd291f09..1b050391c0c90 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include "adf_accel_devices.h" #include "adf_transport.h" @@ -1102,6 +1103,14 @@ static int qat_alg_skcipher_blk_encrypt(struct skcipher_request *req) return qat_alg_skcipher_encrypt(req); } +static int qat_alg_skcipher_xts_encrypt(struct skcipher_request *req) +{ + if (req->cryptlen < XTS_BLOCK_SIZE) + return -EINVAL; + + return qat_alg_skcipher_encrypt(req); +} + static int qat_alg_skcipher_decrypt(struct skcipher_request *req) { struct crypto_skcipher *stfm = crypto_skcipher_reqtfm(req); @@ -1161,6 +1170,15 @@ static int qat_alg_skcipher_blk_decrypt(struct skcipher_request *req) return qat_alg_skcipher_decrypt(req); } + +static int qat_alg_skcipher_xts_decrypt(struct skcipher_request *req) +{ + if (req->cryptlen < XTS_BLOCK_SIZE) + return -EINVAL; + + return qat_alg_skcipher_decrypt(req); +} + static int qat_alg_aead_init(struct crypto_aead *tfm, enum icp_qat_hw_auth_algo hash, const char *hash_name) @@ -1354,8 +1372,8 @@ static struct skcipher_alg qat_skciphers[] = { { .init = qat_alg_skcipher_init_tfm, .exit = qat_alg_skcipher_exit_tfm, .setkey = qat_alg_skcipher_xts_setkey, - .decrypt = qat_alg_skcipher_blk_decrypt, - .encrypt = qat_alg_skcipher_blk_encrypt, + .decrypt = qat_alg_skcipher_xts_decrypt, + .encrypt = qat_alg_skcipher_xts_encrypt, .min_keysize = 2 * AES_MIN_KEY_SIZE, .max_keysize = 2 * AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, -- 2.25.1