[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200703044821.GC23200@gondor.apana.org.au>
Date: Fri, 3 Jul 2020 14:48:22 +1000
From: Herbert Xu <herbert@...dor.apana.org.au>
To: John Allen <john.allen@....com>
Cc: linux-crypto@...r.kernel.org, thomas.lendacky@....com,
davem@...emloft.net, bp@...e.de, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH] crypto: ccp - Fix use of merged scatterlists
On Mon, Jun 22, 2020 at 03:24:02PM -0500, John Allen wrote:
> Running the crypto manager self tests with
> CONFIG_CRYPTO_MANAGER_EXTRA_TESTS may result in several types of errors
> when using the ccp-crypto driver:
>
> alg: skcipher: cbc-des3-ccp encryption failed on test vector 0; expected_error=0, actual_error=-5 ...
>
> alg: skcipher: ctr-aes-ccp decryption overran dst buffer on test vector 0 ...
>
> alg: ahash: sha224-ccp test failed (wrong result) on test vector ...
>
> These errors are the result of improper processing of scatterlists mapped
> for DMA.
>
> Given a scatterlist in which entries are merged as part of mapping the
> scatterlist for DMA, the DMA length of a merged entry will reflect the
> combined length of the entries that were merged. The subsequent
> scatterlist entry will contain DMA information for the scatterlist entry
> after the last merged entry, but the non-DMA information will be that of
> the first merged entry.
>
> The ccp driver does not take this scatterlist merging into account. To
> address this, add a second scatterlist pointer to track the current
> position in the DMA mapped representation of the scatterlist. Both the DMA
> representation and the original representation of the scatterlist must be
> tracked as while most of the driver can use just the DMA representation,
> scatterlist_map_and_copy() must use the original representation and
> expects the scatterlist pointer to be accurate to the original
> representation.
>
> In order to properly walk the original scatterlist, the scatterlist must
> be walked until the combined lengths of the entries seen is equal to the
> DMA length of the current entry being processed in the DMA mapped
> representation.
>
> Fixes: 63b945091a070 ("crypto: ccp - CCP device driver and interface support")
> Signed-off-by: John Allen <john.allen@....com>
> Cc: stable@...r.kernel.org
> ---
> drivers/crypto/ccp/ccp-dev.h | 1 +
> drivers/crypto/ccp/ccp-ops.c | 37 +++++++++++++++++++++++++-----------
> 2 files changed, 27 insertions(+), 11 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists