Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2658189pxa; Mon, 17 Aug 2020 15:44:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzazFk6BGAtSqWuD8ErLMvpuD2/SjjCkl+U2Uad7xgFi6Z0FROagNc4mJ+a4JLTZylZ3NAq X-Received: by 2002:a17:906:69d5:: with SMTP id g21mr16807230ejs.461.1597704296207; Mon, 17 Aug 2020 15:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704296; cv=none; d=google.com; s=arc-20160816; b=defH3zz8OCeu/kUZe8IxgjJyqKHek0I7/T/VpwRq9O6JSK/e08S/bh7SkydD9fykHs LrfKOb2v4rQsYXMqcKObSU+ZtMNheR3+5pgAOQPVs+MXNyMcjNhhhpd595tedKSjb69q YZ9meMHPp8UvP23JjNscDmnEW7YiL8DS8cSgdTaMiabcT0EuZqrG8G9RFyDsARchKFDo hUmCTapZf2YEz5SDYv7C8+0ik4iSQz5Uua2b6eimS4rsnRG2hiOvyCcQThWLpmDtpOZH Myt63cX0zpxRBbqDvXvkvZ23CVOSmYkReWEoCp+OwEhyHWPvk/jj1ZmLyEVWwE8j40e9 +1QA== 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=1EEbl4lyQX2f8/tMKVicu6NZWAXx68+/ZNnaL9OwL7BeQwlvOYnDfF8RIYzH/e3+OC V+kI+gGJAvXqCuV38kync5mo4LJ2X6IoiO2IjF6Df6w/lrWZ/Cv9syc8y5kRdLQDjg/L Iit2gc0dPQ+AmGahzg7B4y6ZVkklbEh5i2wGteUhEs7av5UCShZRaP4NIN0+wGxnv9HA E9KHhvJlOqQ6XBf9Uh6MYDHmtLW18vot4dUkYpF7rA89usyCmUvDzum2CPIK2GjkfBOI Do4sjqVhMzwfs1MZRbk3cpGrQqLR/XLLswv+Y4VM/4BoHooPPwUnMGu8LWaoSbv/rRmU gAaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rjY6txAX; 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 o9si12585096ejr.637.2020.08.17.15.44.33; Mon, 17 Aug 2020 15:44:56 -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=rjY6txAX; 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 S2388680AbgHQTIQ (ORCPT + 99 others); Mon, 17 Aug 2020 15:08:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:53386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387620AbgHQPnM (ORCPT ); Mon, 17 Aug 2020 11:43:12 -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 8BBAC2075B; Mon, 17 Aug 2020 15:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678987; bh=D/f7KeSvbnpfeuO5AHy05pktd39Vhn5bLwVvks2iLkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rjY6txAX1dNQiY3vmlnIiddMCNkv/iQVaZ7g2w1i6Yfrt8USegGflsJ95otgPQuch gqjNpoNhU3x7fBMDg15syK3obAPaHA5ZuQaer13c2XCNXHmxKCdDGQmD4anjgD+IEI sQQBZBGzSuPj/AmyBM2r/y1jsOWNApOll7uv3DcE= 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.7 027/393] crypto: qat - allow xts requests not multiple of block Date: Mon, 17 Aug 2020 17:11:17 +0200 Message-Id: <20200817143820.925882563@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@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