crypto: vmx/xts - reject inputs that are too short
PATCH 1/1 crypto: vmx/xts - reject inputs that are too short
When the kernel XTS implementation was extended to deal with ciphertext stealing in commit 8083b1bf8163 ("crypto: xts - add support for ciphertext stealing"), a check was added to reject inputs that were too short.
However, in the vmx enablement - commit 239668419349 ("crypto: vmx/xts - use fallback for ciphertext stealing"), that check wasn't added to the vmx implementation. This disparity leads to errors like the following:
alg: skcipher: p8_aes_xts encryption unexpectedly succeeded on test vector "random: len=0 klen=64"; expected_error=-22, cfg="random: inplace may_sleep use_finup src_divs=[<flush>66.99%@+10, 33.1%@alignmask+1155]"
Return -EINVAL if asked to operate with a cryptlen smaller than the AES block size. This brings vmx in line with the generic implementation.
--- drivers/crypto/vmx/aes_xts.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/vmx/aes_xts.c +3 -0
@@ -84,6 +84,9 @@ static int p8_aes_xts_crypt(struct skcipher_request *req, int enc)u8 tweak[AES_BLOCK_SIZE ];int ret; +if (req->cryptlen <AES_BLOCK_SIZE ) +return -EINVAL ; +if (!crypto_simd_usable () || (req->cryptlen %XTS_BLOCK_SIZE ) !=0 ) {struct skcipher_request *subreq =skcipher_request_ctx (req);
Signature · 1 line
2.20.1
Herbert Xu
maintainerQuoted 21 lines · Daniel Axtens
When the kernel XTS implementation was extended to deal with ciphertext stealing in commit
8083b1bf8163("crypto: xts - add support for ciphertext stealing"), a check was added to reject inputs that were too short.However, in the vmx enablement - commit 239668419349 ("crypto: vmx/xts - use fallback for ciphertext stealing"), that check wasn't added to the vmx implementation. This disparity leads to errors like the following:
alg: skcipher:
p8_aes_xtsencryption unexpectedly succeeded on test vector "random: len=0 klen=64"; expected_error=-22, cfg="random: inplacemay_sleepuse_finupsrc_divs=[<flush>66.99%@+10, 33.1%@alignmask+1155]"Return
-EINVALif asked to operate with a cryptlen smaller than the AES block size. This brings vmx in line with the generic implementation.Reported-by Erhard Furtner <[email protected]>Fixes 239668419349 ("crypto: vmx/xts - use fallback for ciphertext stealing")Cc Ard Biesheuvel <[email protected]>Cc [email protected] # v5.4+Signed-off-by Michael Ellerman <[email protected]>[dja: commit message]Signed-off-by Daniel Axtens <[email protected]>
Quoted 3 lines
--- drivers/crypto/vmx/aes_xts.c | 3 +++ 1 file changed, 3 insertions(+)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt