From: Greg Kroah-Hartman Date: Tue, 17 Sep 2019 12:47:23 +0000 (+0200) Subject: 4.4-stable patches X-Git-Tag: v4.14.145~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5fdd16be58b41bd5974a60fdf8cab69c0c23481b;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: crypto-talitos-check-aes-key-size.patch crypto-talitos-check-data-blocksize-in-ablkcipher.patch --- diff --git a/queue-4.4/crypto-talitos-check-aes-key-size.patch b/queue-4.4/crypto-talitos-check-aes-key-size.patch new file mode 100644 index 00000000000..9f9a07f7ff5 --- /dev/null +++ b/queue-4.4/crypto-talitos-check-aes-key-size.patch @@ -0,0 +1,51 @@ +From 1ba34e71e9e56ac29a52e0d42b6290f3dc5bfd90 Mon Sep 17 00:00:00 2001 +From: Christophe Leroy +Date: Tue, 21 May 2019 13:34:10 +0000 +Subject: crypto: talitos - check AES key size + +From: Christophe Leroy + +commit 1ba34e71e9e56ac29a52e0d42b6290f3dc5bfd90 upstream. + +Although the HW accepts any size and silently truncates +it to the correct length, the extra tests expects EINVAL +to be returned when the key size is not valid. + +Signed-off-by: Christophe Leroy +Fixes: 4de9d0b547b9 ("crypto: talitos - Add ablkcipher algorithms") +Signed-off-by: Herbert Xu +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/crypto/talitos.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +--- a/drivers/crypto/talitos.c ++++ b/drivers/crypto/talitos.c +@@ -1426,6 +1426,18 @@ static void unmap_sg_talitos_ptr(struct + } + } + ++static int ablkcipher_aes_setkey(struct crypto_ablkcipher *cipher, ++ const u8 *key, unsigned int keylen) ++{ ++ if (keylen == AES_KEYSIZE_128 || keylen == AES_KEYSIZE_192 || ++ keylen == AES_KEYSIZE_256) ++ return ablkcipher_setkey(cipher, key, keylen); ++ ++ crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); ++ ++ return -EINVAL; ++} ++ + static void common_nonsnoop_unmap(struct device *dev, + struct talitos_edesc *edesc, + struct ablkcipher_request *areq) +@@ -2379,6 +2391,7 @@ static struct talitos_alg_template drive + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, ++ .setkey = ablkcipher_aes_setkey, + } + }, + .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | diff --git a/queue-4.4/crypto-talitos-check-data-blocksize-in-ablkcipher.patch b/queue-4.4/crypto-talitos-check-data-blocksize-in-ablkcipher.patch new file mode 100644 index 00000000000..b3145f22302 --- /dev/null +++ b/queue-4.4/crypto-talitos-check-data-blocksize-in-ablkcipher.patch @@ -0,0 +1,58 @@ +From ee483d32ee1a1a7f7d7e918fbc350c790a5af64a Mon Sep 17 00:00:00 2001 +From: Christophe Leroy +Date: Tue, 21 May 2019 13:34:12 +0000 +Subject: crypto: talitos - check data blocksize in ablkcipher. + +From: Christophe Leroy + +commit ee483d32ee1a1a7f7d7e918fbc350c790a5af64a upstream. + +When data size is not a multiple of the alg's block size, +the SEC generates an error interrupt and dumps the registers. +And for NULL size, the SEC does just nothing and the interrupt +is awaited forever. + +This patch ensures the data size is correct before submitting +the request to the SEC engine. + +Signed-off-by: Christophe Leroy +Fixes: 4de9d0b547b9 ("crypto: talitos - Add ablkcipher algorithms") +Signed-off-by: Herbert Xu +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/crypto/talitos.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +--- a/drivers/crypto/talitos.c ++++ b/drivers/crypto/talitos.c +@@ -1641,6 +1641,14 @@ static int ablkcipher_encrypt(struct abl + struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); + struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); + struct talitos_edesc *edesc; ++ unsigned int blocksize = ++ crypto_tfm_alg_blocksize(crypto_ablkcipher_tfm(cipher)); ++ ++ if (!areq->nbytes) ++ return 0; ++ ++ if (areq->nbytes % blocksize) ++ return -EINVAL; + + /* allocate extended descriptor */ + edesc = ablkcipher_edesc_alloc(areq, true); +@@ -1658,6 +1666,14 @@ static int ablkcipher_decrypt(struct abl + struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); + struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); + struct talitos_edesc *edesc; ++ unsigned int blocksize = ++ crypto_tfm_alg_blocksize(crypto_ablkcipher_tfm(cipher)); ++ ++ if (!areq->nbytes) ++ return 0; ++ ++ if (areq->nbytes % blocksize) ++ return -EINVAL; + + /* allocate extended descriptor */ + edesc = ablkcipher_edesc_alloc(areq, false); diff --git a/queue-4.4/series b/queue-4.4/series index f3433b7d2b0..16f86189d9e 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -19,3 +19,5 @@ mips-vdso-prevent-use-of-smp_processor_id.patch mips-vdso-use-same-m-float-cflag-as-the-kernel-proper.patch clk-rockchip-don-t-yell-about-bad-mmc-phases-when-getting.patch driver-core-fix-use-after-free-and-double-free-on-glue-directory.patch +crypto-talitos-check-aes-key-size.patch +crypto-talitos-check-data-blocksize-in-ablkcipher.patch