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:

- fix crashes in skcipher/shash from zero-length input.

- fix softirq GFP_KERNEL allocation in shash_setkey_unaligned.

- error path bug fix in xts create function.

- fix compiler warning regressions in axis and stm32

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: shash - Fix zero-length shash ahash digest crash
crypto: skcipher - Fix crash on zero-length input
crypto: shash - Fix a sleep-in-atomic bug in shash_setkey_unaligned
crypto: xts - Fix an error handling path in 'create()'
crypto: stm32 - Try to fix hash padding
crypto: axis - hide an unused variable

+32 -20
+6 -4
crypto/shash.c
··· 41 41 int err; 42 42 43 43 absize = keylen + (alignmask & ~(crypto_tfm_ctx_alignment() - 1)); 44 - buffer = kmalloc(absize, GFP_KERNEL); 44 + buffer = kmalloc(absize, GFP_ATOMIC); 45 45 if (!buffer) 46 46 return -ENOMEM; 47 47 ··· 275 275 276 276 int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc) 277 277 { 278 - struct scatterlist *sg = req->src; 279 - unsigned int offset = sg->offset; 280 278 unsigned int nbytes = req->nbytes; 279 + struct scatterlist *sg; 280 + unsigned int offset; 281 281 int err; 282 282 283 - if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) { 283 + if (nbytes && 284 + (sg = req->src, offset = sg->offset, 285 + nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset))) { 284 286 void *data; 285 287 286 288 data = kmap_atomic(sg_page(sg));
+11 -6
crypto/skcipher.c
··· 426 426 427 427 static int skcipher_walk_first(struct skcipher_walk *walk) 428 428 { 429 - walk->nbytes = 0; 430 - 431 429 if (WARN_ON_ONCE(in_irq())) 432 430 return -EDEADLK; 433 - 434 - if (unlikely(!walk->total)) 435 - return 0; 436 431 437 432 walk->buffer = NULL; 438 433 if (unlikely(((unsigned long)walk->iv & walk->alignmask))) { ··· 447 452 { 448 453 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); 449 454 455 + walk->total = req->cryptlen; 456 + walk->nbytes = 0; 457 + 458 + if (unlikely(!walk->total)) 459 + return 0; 460 + 450 461 scatterwalk_start(&walk->in, req->src); 451 462 scatterwalk_start(&walk->out, req->dst); 452 463 453 - walk->total = req->cryptlen; 454 464 walk->iv = req->iv; 455 465 walk->oiv = req->iv; 456 466 ··· 508 508 { 509 509 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 510 510 int err; 511 + 512 + walk->nbytes = 0; 513 + 514 + if (unlikely(!walk->total)) 515 + return 0; 511 516 512 517 walk->flags &= ~SKCIPHER_WALK_PHYS; 513 518
+4 -2
crypto/xts.c
··· 554 554 ctx->name[len - 1] = 0; 555 555 556 556 if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME, 557 - "xts(%s)", ctx->name) >= CRYPTO_MAX_ALG_NAME) 558 - return -ENAMETOOLONG; 557 + "xts(%s)", ctx->name) >= CRYPTO_MAX_ALG_NAME) { 558 + err = -ENAMETOOLONG; 559 + goto err_drop_spawn; 560 + } 559 561 } else 560 562 goto err_drop_spawn; 561 563
+2 -2
drivers/crypto/axis/artpec6_crypto.c
··· 349 349 /* The crypto framework makes it hard to avoid this global. */ 350 350 static struct device *artpec6_crypto_dev; 351 351 352 - static struct dentry *dbgfs_root; 353 - 354 352 #ifdef CONFIG_FAULT_INJECTION 355 353 static DECLARE_FAULT_ATTR(artpec6_crypto_fail_status_read); 356 354 static DECLARE_FAULT_ATTR(artpec6_crypto_fail_dma_array_full); ··· 2981 2983 u32 *flag; 2982 2984 char *desc; 2983 2985 }; 2986 + 2987 + static struct dentry *dbgfs_root; 2984 2988 2985 2989 static void artpec6_crypto_init_debugfs(void) 2986 2990 {
+9 -6
drivers/crypto/stm32/stm32-hash.c
··· 553 553 { 554 554 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(hdev->req); 555 555 struct scatterlist sg[1], *tsg; 556 - int err = 0, len = 0, reg, ncp; 556 + int err = 0, len = 0, reg, ncp = 0; 557 557 unsigned int i; 558 - const u32 *buffer = (const u32 *)rctx->buffer; 558 + u32 *buffer = (void *)rctx->buffer; 559 559 560 560 rctx->sg = hdev->req->src; 561 561 rctx->total = hdev->req->nbytes; ··· 620 620 reg |= HASH_CR_DMAA; 621 621 stm32_hash_write(hdev, HASH_CR, reg); 622 622 623 - for (i = 0; i < DIV_ROUND_UP(ncp, sizeof(u32)); i++) 624 - stm32_hash_write(hdev, HASH_DIN, buffer[i]); 625 - 626 - stm32_hash_set_nblw(hdev, ncp); 623 + if (ncp) { 624 + memset(buffer + ncp, 0, 625 + DIV_ROUND_UP(ncp, sizeof(u32)) - ncp); 626 + writesl(hdev->io_base + HASH_DIN, buffer, 627 + DIV_ROUND_UP(ncp, sizeof(u32))); 628 + } 629 + stm32_hash_set_nblw(hdev, DIV_ROUND_UP(ncp, sizeof(u32))); 627 630 reg = stm32_hash_read(hdev, HASH_STR); 628 631 reg |= HASH_STR_DCAL; 629 632 stm32_hash_write(hdev, HASH_STR, reg);