Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto fixes from Herbert Xu:

- vmalloc stack regression in CCM

- Build problem in CRC32 on ARM

- Memory leak in cavium

- Missing Kconfig dependencies in atmel and mediatek

- XTS Regression on some platforms (s390 and ppc)

- Memory overrun in CCM test vector

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: vmx - Use skcipher for xts fallback
crypto: vmx - Use skcipher for cbc fallback
crypto: testmgr - Pad aes_ccm_enc_tv_template vector
crypto: arm/crc32 - add build time test for CRC instruction support
crypto: arm/crc32 - fix build error with outdated binutils
crypto: ccm - move cbcmac input off the stack
crypto: xts - Propagate NEED_FALLBACK bit
crypto: api - Add crypto_requires_off helper
crypto: atmel - CRYPTO_DEV_MEDIATEK should depend on HAS_DMA
crypto: atmel - CRYPTO_DEV_ATMEL_TDES and CRYPTO_DEV_ATMEL_SHA should depend on HAS_DMA
crypto: cavium - fix leak on curr if curr->head fails to be allocated
crypto: cavium - Fix couple of static checker errors

+79 -54
+11 -1
arch/arm/crypto/Makefile
··· 15 15 ce-obj-$(CONFIG_CRYPTO_SHA2_ARM_CE) += sha2-arm-ce.o 16 16 ce-obj-$(CONFIG_CRYPTO_GHASH_ARM_CE) += ghash-arm-ce.o 17 17 ce-obj-$(CONFIG_CRYPTO_CRCT10DIF_ARM_CE) += crct10dif-arm-ce.o 18 - ce-obj-$(CONFIG_CRYPTO_CRC32_ARM_CE) += crc32-arm-ce.o 18 + crc-obj-$(CONFIG_CRYPTO_CRC32_ARM_CE) += crc32-arm-ce.o 19 + 20 + ifneq ($(crc-obj-y)$(crc-obj-m),) 21 + ifeq ($(call as-instr,.arch armv8-a\n.arch_extension crc,y,n),y) 22 + ce-obj-y += $(crc-obj-y) 23 + ce-obj-m += $(crc-obj-m) 24 + else 25 + $(warning These CRC Extensions modules need binutils 2.23 or higher) 26 + $(warning $(crc-obj-y) $(crc-obj-m)) 27 + endif 28 + endif 19 29 20 30 ifneq ($(ce-obj-y)$(ce-obj-m),) 21 31 ifeq ($(call as-instr,.fpu crypto-neon-fp-armv8,y,n),y)
+1 -1
arch/arm/crypto/crc32-ce-core.S
··· 135 135 vld1.8 {q3-q4}, [BUF, :128]! 136 136 vmov.i8 qzr, #0 137 137 vmov.i8 qCONSTANT, #0 138 - vmov dCONSTANTl[0], CRC 138 + vmov.32 dCONSTANTl[0], CRC 139 139 veor.8 d2, d2, dCONSTANTl 140 140 sub LEN, LEN, #0x40 141 141 cmp LEN, #0x40
+3 -2
crypto/ccm.c
··· 45 45 46 46 struct crypto_ccm_req_priv_ctx { 47 47 u8 odata[16]; 48 + u8 idata[16]; 48 49 u8 auth_tag[16]; 49 50 u32 flags; 50 51 struct scatterlist src[3]; ··· 184 183 AHASH_REQUEST_ON_STACK(ahreq, ctx->mac); 185 184 unsigned int assoclen = req->assoclen; 186 185 struct scatterlist sg[3]; 187 - u8 odata[16]; 188 - u8 idata[16]; 186 + u8 *odata = pctx->odata; 187 + u8 *idata = pctx->idata; 189 188 int ilen, err; 190 189 191 190 /* format control data for input */
+1 -1
crypto/testmgr.h
··· 22691 22691 "\x09\x75\x9a\x9b\x3c\x9b\x27\x39", 22692 22692 .klen = 32, 22693 22693 .iv = "\x03\xf9\xd9\x4e\x63\xb5\x3d\x9d" 22694 - "\x43\xf6\x1e\x50", 22694 + "\x43\xf6\x1e\x50\0\0\0\0", 22695 22695 .assoc = "\x57\xf5\x6b\x8b\x57\x5c\x3d\x3b" 22696 22696 "\x13\x02\x01\x0c\x83\x4c\x96\x35" 22697 22697 "\x8e\xd6\x39\xcf\x7d\x14\x9b\x94"
+8 -6
crypto/xts.c
··· 463 463 struct xts_instance_ctx *ctx; 464 464 struct skcipher_alg *alg; 465 465 const char *cipher_name; 466 + u32 mask; 466 467 int err; 467 468 468 469 algt = crypto_get_attr_type(tb); ··· 484 483 ctx = skcipher_instance_ctx(inst); 485 484 486 485 crypto_set_skcipher_spawn(&ctx->spawn, skcipher_crypto_instance(inst)); 487 - err = crypto_grab_skcipher(&ctx->spawn, cipher_name, 0, 488 - crypto_requires_sync(algt->type, 489 - algt->mask)); 486 + 487 + mask = crypto_requires_off(algt->type, algt->mask, 488 + CRYPTO_ALG_NEED_FALLBACK | 489 + CRYPTO_ALG_ASYNC); 490 + 491 + err = crypto_grab_skcipher(&ctx->spawn, cipher_name, 0, mask); 490 492 if (err == -ENOENT) { 491 493 err = -ENAMETOOLONG; 492 494 if (snprintf(ctx->name, CRYPTO_MAX_ALG_NAME, "ecb(%s)", 493 495 cipher_name) >= CRYPTO_MAX_ALG_NAME) 494 496 goto err_free_inst; 495 497 496 - err = crypto_grab_skcipher(&ctx->spawn, ctx->name, 0, 497 - crypto_requires_sync(algt->type, 498 - algt->mask)); 498 + err = crypto_grab_skcipher(&ctx->spawn, ctx->name, 0, mask); 499 499 } 500 500 501 501 if (err)
+3
drivers/crypto/Kconfig
··· 459 459 460 460 config CRYPTO_DEV_ATMEL_TDES 461 461 tristate "Support for Atmel DES/TDES hw accelerator" 462 + depends on HAS_DMA 462 463 depends on ARCH_AT91 || COMPILE_TEST 463 464 select CRYPTO_DES 464 465 select CRYPTO_BLKCIPHER ··· 473 472 474 473 config CRYPTO_DEV_ATMEL_SHA 475 474 tristate "Support for Atmel SHA hw accelerator" 475 + depends on HAS_DMA 476 476 depends on ARCH_AT91 || COMPILE_TEST 477 477 select CRYPTO_HASH 478 478 help ··· 585 583 586 584 config CRYPTO_DEV_MEDIATEK 587 585 tristate "MediaTek's EIP97 Cryptographic Engine driver" 586 + depends on HAS_DMA 588 587 depends on (ARM && ARCH_MEDIATEK) || COMPILE_TEST 589 588 select CRYPTO_AES 590 589 select CRYPTO_AEAD
+4 -1
drivers/crypto/cavium/cpt/cptvf_main.c
··· 242 242 if (!curr->head) { 243 243 dev_err(&pdev->dev, "Command Q (%d) chunk (%d) allocation failed\n", 244 244 i, queue->nchunks); 245 + kfree(curr); 245 246 goto cmd_qfail; 246 247 } 247 248 ··· 816 815 { 817 816 struct cpt_vf *cptvf = pci_get_drvdata(pdev); 818 817 819 - if (!cptvf) 818 + if (!cptvf) { 820 819 dev_err(&pdev->dev, "Invalid CPT-VF device\n"); 820 + return; 821 + } 821 822 822 823 /* Convey DOWN to PF */ 823 824 if (cptvf_send_vf_down(cptvf)) {
+2 -2
drivers/crypto/cavium/cpt/cptvf_reqmanager.c
··· 330 330 { 331 331 struct pci_dev *pdev = cptvf->pdev; 332 332 333 - if (!info || !cptvf) { 334 - dev_err(&pdev->dev, "Input params are incorrect for post processing\n"); 333 + if (!info) { 334 + dev_err(&pdev->dev, "incorrect cpt_info_buffer for post processing\n"); 335 335 return; 336 336 } 337 337
+24 -23
drivers/crypto/vmx/aes_cbc.c
··· 27 27 #include <asm/switch_to.h> 28 28 #include <crypto/aes.h> 29 29 #include <crypto/scatterwalk.h> 30 + #include <crypto/skcipher.h> 30 31 31 32 #include "aesp8-ppc.h" 32 33 33 34 struct p8_aes_cbc_ctx { 34 - struct crypto_blkcipher *fallback; 35 + struct crypto_skcipher *fallback; 35 36 struct aes_key enc_key; 36 37 struct aes_key dec_key; 37 38 }; ··· 40 39 static int p8_aes_cbc_init(struct crypto_tfm *tfm) 41 40 { 42 41 const char *alg; 43 - struct crypto_blkcipher *fallback; 42 + struct crypto_skcipher *fallback; 44 43 struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm); 45 44 46 45 if (!(alg = crypto_tfm_alg_name(tfm))) { ··· 48 47 return -ENOENT; 49 48 } 50 49 51 - fallback = 52 - crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK); 50 + fallback = crypto_alloc_skcipher(alg, 0, 51 + CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK); 52 + 53 53 if (IS_ERR(fallback)) { 54 54 printk(KERN_ERR 55 55 "Failed to allocate transformation for '%s': %ld\n", ··· 58 56 return PTR_ERR(fallback); 59 57 } 60 58 printk(KERN_INFO "Using '%s' as fallback implementation.\n", 61 - crypto_tfm_alg_driver_name((struct crypto_tfm *) fallback)); 59 + crypto_skcipher_driver_name(fallback)); 62 60 63 - crypto_blkcipher_set_flags( 61 + 62 + crypto_skcipher_set_flags( 64 63 fallback, 65 - crypto_blkcipher_get_flags((struct crypto_blkcipher *)tfm)); 64 + crypto_skcipher_get_flags((struct crypto_skcipher *)tfm)); 66 65 ctx->fallback = fallback; 67 66 68 67 return 0; ··· 74 71 struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm); 75 72 76 73 if (ctx->fallback) { 77 - crypto_free_blkcipher(ctx->fallback); 74 + crypto_free_skcipher(ctx->fallback); 78 75 ctx->fallback = NULL; 79 76 } 80 77 } ··· 94 91 pagefault_enable(); 95 92 preempt_enable(); 96 93 97 - ret += crypto_blkcipher_setkey(ctx->fallback, key, keylen); 94 + ret += crypto_skcipher_setkey(ctx->fallback, key, keylen); 98 95 return ret; 99 96 } 100 97 ··· 106 103 struct blkcipher_walk walk; 107 104 struct p8_aes_cbc_ctx *ctx = 108 105 crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); 109 - struct blkcipher_desc fallback_desc = { 110 - .tfm = ctx->fallback, 111 - .info = desc->info, 112 - .flags = desc->flags 113 - }; 114 106 115 107 if (in_interrupt()) { 116 - ret = crypto_blkcipher_encrypt(&fallback_desc, dst, src, 117 - nbytes); 108 + SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback); 109 + skcipher_request_set_tfm(req, ctx->fallback); 110 + skcipher_request_set_callback(req, desc->flags, NULL, NULL); 111 + skcipher_request_set_crypt(req, src, dst, nbytes, desc->info); 112 + ret = crypto_skcipher_encrypt(req); 113 + skcipher_request_zero(req); 118 114 } else { 119 115 preempt_disable(); 120 116 pagefault_disable(); ··· 146 144 struct blkcipher_walk walk; 147 145 struct p8_aes_cbc_ctx *ctx = 148 146 crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); 149 - struct blkcipher_desc fallback_desc = { 150 - .tfm = ctx->fallback, 151 - .info = desc->info, 152 - .flags = desc->flags 153 - }; 154 147 155 148 if (in_interrupt()) { 156 - ret = crypto_blkcipher_decrypt(&fallback_desc, dst, src, 157 - nbytes); 149 + SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback); 150 + skcipher_request_set_tfm(req, ctx->fallback); 151 + skcipher_request_set_callback(req, desc->flags, NULL, NULL); 152 + skcipher_request_set_crypt(req, src, dst, nbytes, desc->info); 153 + ret = crypto_skcipher_decrypt(req); 154 + skcipher_request_zero(req); 158 155 } else { 159 156 preempt_disable(); 160 157 pagefault_disable();
+16 -16
drivers/crypto/vmx/aes_xts.c
··· 28 28 #include <crypto/aes.h> 29 29 #include <crypto/scatterwalk.h> 30 30 #include <crypto/xts.h> 31 + #include <crypto/skcipher.h> 31 32 32 33 #include "aesp8-ppc.h" 33 34 34 35 struct p8_aes_xts_ctx { 35 - struct crypto_blkcipher *fallback; 36 + struct crypto_skcipher *fallback; 36 37 struct aes_key enc_key; 37 38 struct aes_key dec_key; 38 39 struct aes_key tweak_key; ··· 42 41 static int p8_aes_xts_init(struct crypto_tfm *tfm) 43 42 { 44 43 const char *alg; 45 - struct crypto_blkcipher *fallback; 44 + struct crypto_skcipher *fallback; 46 45 struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm); 47 46 48 47 if (!(alg = crypto_tfm_alg_name(tfm))) { ··· 50 49 return -ENOENT; 51 50 } 52 51 53 - fallback = 54 - crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK); 52 + fallback = crypto_alloc_skcipher(alg, 0, 53 + CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK); 55 54 if (IS_ERR(fallback)) { 56 55 printk(KERN_ERR 57 56 "Failed to allocate transformation for '%s': %ld\n", ··· 59 58 return PTR_ERR(fallback); 60 59 } 61 60 printk(KERN_INFO "Using '%s' as fallback implementation.\n", 62 - crypto_tfm_alg_driver_name((struct crypto_tfm *) fallback)); 61 + crypto_skcipher_driver_name(fallback)); 63 62 64 - crypto_blkcipher_set_flags( 63 + crypto_skcipher_set_flags( 65 64 fallback, 66 - crypto_blkcipher_get_flags((struct crypto_blkcipher *)tfm)); 65 + crypto_skcipher_get_flags((struct crypto_skcipher *)tfm)); 67 66 ctx->fallback = fallback; 68 67 69 68 return 0; ··· 74 73 struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm); 75 74 76 75 if (ctx->fallback) { 77 - crypto_free_blkcipher(ctx->fallback); 76 + crypto_free_skcipher(ctx->fallback); 78 77 ctx->fallback = NULL; 79 78 } 80 79 } ··· 99 98 pagefault_enable(); 100 99 preempt_enable(); 101 100 102 - ret += crypto_blkcipher_setkey(ctx->fallback, key, keylen); 101 + ret += crypto_skcipher_setkey(ctx->fallback, key, keylen); 103 102 return ret; 104 103 } 105 104 ··· 114 113 struct blkcipher_walk walk; 115 114 struct p8_aes_xts_ctx *ctx = 116 115 crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); 117 - struct blkcipher_desc fallback_desc = { 118 - .tfm = ctx->fallback, 119 - .info = desc->info, 120 - .flags = desc->flags 121 - }; 122 116 123 117 if (in_interrupt()) { 124 - ret = enc ? crypto_blkcipher_encrypt(&fallback_desc, dst, src, nbytes) : 125 - crypto_blkcipher_decrypt(&fallback_desc, dst, src, nbytes); 118 + SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback); 119 + skcipher_request_set_tfm(req, ctx->fallback); 120 + skcipher_request_set_callback(req, desc->flags, NULL, NULL); 121 + skcipher_request_set_crypt(req, src, dst, nbytes, desc->info); 122 + ret = enc? crypto_skcipher_encrypt(req) : crypto_skcipher_decrypt(req); 123 + skcipher_request_zero(req); 126 124 } else { 127 125 preempt_disable(); 128 126 pagefault_disable();
+6 -1
include/crypto/algapi.h
··· 360 360 return crypto_attr_alg(tb[1], type, mask); 361 361 } 362 362 363 + static inline int crypto_requires_off(u32 type, u32 mask, u32 off) 364 + { 365 + return (type ^ off) & mask & off; 366 + } 367 + 363 368 /* 364 369 * Returns CRYPTO_ALG_ASYNC if type/mask requires the use of sync algorithms. 365 370 * Otherwise returns zero. 366 371 */ 367 372 static inline int crypto_requires_sync(u32 type, u32 mask) 368 373 { 369 - return (type ^ CRYPTO_ALG_ASYNC) & mask & CRYPTO_ALG_ASYNC; 374 + return crypto_requires_off(type, mask, CRYPTO_ALG_ASYNC); 370 375 } 371 376 372 377 noinline unsigned long __crypto_memneq(const void *a, const void *b, size_t size);