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.

crypto: ahash - Enforce MAX_SYNC_HASH_REQSIZE for sync ahash

As sync ahash algorithms (currently there are none) are used without
a fallback, ensure that they obey the MAX_SYNC_HASH_REQSIZE rule
just like shash algorithms.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+18 -9
+18 -9
crypto/ahash.c
··· 760 760 761 761 tfm->exit = crypto_ahash_exit_tfm; 762 762 763 - if (!alg->init_tfm) { 764 - if (!tfm->__crt_alg->cra_init) 765 - return 0; 766 - 763 + if (alg->init_tfm) 764 + err = alg->init_tfm(hash); 765 + else if (tfm->__crt_alg->cra_init) 767 766 err = tfm->__crt_alg->cra_init(tfm); 768 - if (err) 769 - goto out_free_sync_hash; 770 - 767 + else 771 768 return 0; 772 - } 773 769 774 - err = alg->init_tfm(hash); 775 770 if (err) 776 771 goto out_free_sync_hash; 777 772 773 + if (!ahash_is_async(hash) && crypto_ahash_reqsize(hash) > 774 + MAX_SYNC_HASH_REQSIZE) 775 + goto out_exit_tfm; 776 + 778 777 return 0; 779 778 779 + out_exit_tfm: 780 + if (alg->exit_tfm) 781 + alg->exit_tfm(hash); 782 + else if (tfm->__crt_alg->cra_exit) 783 + tfm->__crt_alg->cra_exit(tfm); 784 + err = -EINVAL; 780 785 out_free_sync_hash: 781 786 crypto_free_ahash(fb); 782 787 return err; ··· 957 952 return -EINVAL; 958 953 959 954 if (base->cra_reqsize && base->cra_reqsize < alg->halg.statesize) 955 + return -EINVAL; 956 + 957 + if (!(base->cra_flags & CRYPTO_ALG_ASYNC) && 958 + base->cra_reqsize > MAX_SYNC_HASH_REQSIZE) 960 959 return -EINVAL; 961 960 962 961 err = hash_prepare_alg(&alg->halg);